Setup several domain names on one VPS

How to setup several domain names on one server, or VPS.

First we create the folder of the respective website domain name :

sudo mkdir -p /var/www/

Then we grant the permissions :

sudo chown -R $USER:$USER /var/www/

To allow everyone to see it :

sudo chmod -R 755 /var/www

We create an index page :

sudo nano /var/www/

Here is what we put inside the index.html :

Success: You Have Set Up a Virtual Host

Then we create the virtual host file :

sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/

We open the config file :

sudo nano /etc/apache2/sites-available/

We set the following lines :


DocumentRoot /var/www/

We save and exit (Ctrl+O, Ctrl+X).

Finally, we activate the host :

sudo a2ensite

We restart Apache :

sudo service apache2 restart