Create new virtual host
You can create your own virtual hosts to run multiple websites off of one web server. The simplest way to create a new virtual host is to copy and rename the default file (/etc/apache2/sites-available/000-default.conf), and then modify the directives to point to your new website. Here are the required steps:
1. Create a new configuration file by copying and renaming the default configuration file.
2. Open the new file in a text editor of your choice.
3. Change the ServerAdmin directive to an email that the site administrator can receive emails through.
4. Add a new directive called ServerName. This directive will specify the domain name your site will answer to. This will most likely be your domain.
5. Change the DocumentRoot directive to specify the directory that will contain the webpage files. Make sure that the directory already exists.
6. Activate the website with the a2ensite command.
7. Restart Apache in order for the changes to take effect.
Here is an example procedure:
1. We will first create a new directory that will contain files that make up our new website:
2. We will then create a simple HTML page that will be displayed when the user access our website. We will create this file under the /var/www/newWebsite/ directory and name it index.html:
3. We will then create a new virtual host file by copying and renaming the default virtual host file (000-default.conf):
4. We will now open our new file and edit it to suit our new website. We will configure the ServerName directive to our domain name, which is linux-ub. We will also set the new log files:
5. Enable the website using the a2ensite command and restart the Apache service:
6. Now we can browse to our new website using the domain name we’ve specified. We should get the following content: