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 Windows Subsystem for Linux 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

In the example bellow, replace Server Admin, Server Name, Server Alias, Document Root with your own settings. When your virtual host uses a different port, make sure to add a ‘listen 000′ to the apache2 ports.conf!

<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 stop apache2.service, sudo systemctl start apache2.service
sudo systemctl restart apache2.service
sudo systemctl status apache2.service

See also: