TIL: How to Set Up Virtual Hosts on Apache

Create a virtual host configuration file site-name.conf for the site:

sudo vim /etc/apache2/sites-available/site-name.conf

Inside the file:

<VirtualHost *:80>
    ServerAdmin email
    ServerName domain name
    ServerAlias domain name
    DocumentRoot path to folder no slash at the end
    ErrorLog path to error log
    CustomLog path to access log

    <Directory />
        Options FollowSymLinks
        AllowOverride All

Add the site to the host file:

sudo vim /etc/hosts

Inside the file: localhost.localdomain localhost stashofyarn

Enable the site:

sudo a2ensite site-name.conf

Reload the Apache service in sudo mode:

sudo service apache2 reload

Leave a Reply

Your email address will not be published. Required fields are marked *