Create a new virtual host configuration
In Apache, the virtual host file allows you to specify multiple configuration parameters using individual configuration files which can then be selectively activated and deactivated when necessary. Since your installation uses a largely default configuration, your configuration file will not require much modification.
Perform the following steps to create and activate a new virtual host configuration file for your Statamic site:
In the terminal, change to the sites available directory:
cd /etc/apache2/sites-availableCreate a new virtual host configuration file for your Statamic site by copying the "000-default.conf" file. There isn't a strict naming requirement, but Techwriting.io recommends giving it the same name as your project folder:
cp 000-default.conf exampleSite.confUsing VIM, open your new .conf file:
sudo vim exampleSite.confAppend your site directory to the "DocumentRoot: /var/www/html/" configuration parameter:
DocumentRoot: /var/www/html/exampleSite/Save your configuration file with the following keystrokes:
:w:qENTER
Enable your virtual host file using the
a2ensitecommand:sudo a2ensite exampleSite.confValidate your configuration file by running the
apachectlcommand with the-toption to check for syntax errors:sudo apache2ctl -tRestart Apache to apply the new configuration:
sudo apache2ctl restart