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

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

11066 views
d

By. Jacob

Edited: 2020-03-21 14:32

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.

Note. If you prefer to create symbolic links, you can also try the symbolic-link-create.sh wrapper script in the humanize project, which might be easier than using the ln command directly.

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.

Tell us what you think:

  1. Understanding file permissions in Unix / Linux based systems, and how to make files immutable.
  2. In this article I will explain how to enable a swapfile on small instances, and why it might be useful, even if you do have enough physical memory.
  3. How to determine an optimal value for pm.max_children and related php-fpm settings for your server and web applications.
  4. Tutorial showing how to configure a VirtualBox Guest VM with HOST-only and NAT adapter, while using the WWW folder from the HOST OS.
  5. You may have wondered what the /etc/php/8.0/conf.d/ directory is for in Debian and Ubuntu, and whether it is better to edit the conf.d files than editing php.ini directly; find out in this Tutorial.

More in: Linux servers