Configure Apache

In the previous blog we installed Apache. This blog contains the instructions to configure Apache to run a development website. This blog is part of the WSL blogs.

Run on boot

sudo systemctl enable apache2

Create a folder for your website

sudo mkdir -p /var/www/mywebsite
sudo chown demouser /var/www/mywebsite
sudo chmod -R 755 /var/www/mywebsite 

Setup a virtual host

sudo nano /etc/apache2/sites-available/mywebsite.com.conf

Example configuration

Replace the information for the ServerAdmin, ServerName, ServerAlias, DocumentRoot and fields with your own settings.

<VirtualHost *:80>
    ServerAdmin demouser@mywebsite.com
    ServerName mywebsite.com
    ServerAlias mywebsite.com
    DocumentRoot /var/www/mywebsite.com
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Disable site

sudo a2dissite 000-default.conf

Enable site

sudo a2ensite mywebsite.com.conf

Refresh Apache

sudo systemctl reload apache2
sudo systemctl restart apache2
sudo apache2ctl configtest

See also: