Share via:

Create Symbolic Link to V-host .conf File in Sites-Available

How to create symbolic links for Apache2 v-host files in sites-available.


Edited: 2019-12-09 03:51

This is just a simple quick-reference on how to easily create a symbolic link to a v-host file in the sites-available directory when configuring apache. Simply navigate to the sites-enabled directory, and use the ln -s command as shown below.

cd /etc/apache2/sites-enabled
sudo ln -s /etc/apache2/sites-available/subdomain-example-com.conf

Note. The -s option creates a symbolic link.

This will create a symbolic link in sites-enabled. The link will point to the file in the sites-available directory, and effectively activate the site configuration.

Today, instead of doing the above, we can also use the a2ensite command:

sudo a2ensite subdomain-example-com.conf

We can engage this command from anywhere.

Multiple v-host files vs one big file

When hosting multiple sites with the same Apache2 HTTP server, you would typically maintain a separate v-host file for each site, because this may allow your to more easily access the settings of each site.

It is also possible to keep all sites in the same file, often this file will be called 000-default.conf.

Note. Using one big file has caused problems with letsencrypt, which for some reason does/did not support one-big-file. You should therefor check if this situation has changed if you plan to use letsencrypt with multiple sites on the same server.