Code Affairs Web Technologies!

widgets Add Virtual Host on Apache

We have installed apache2 and Ubuntu server on our virtual machine. Now let’s define a new domain.

Go to /etc/apache2/sites-available and look the directory. There is a file named 000-default.conf copy and rename with the full domain name with .conf

cp 000-default.conf

Then open the file with the editor. Add the required information to the file.

DocumentRoot /var/www/virtualsites/
<Directory "/var/www/virtualsites/">
    AllowOverride All

Create a directory:

mkdir -p /var/www/virtualsites/

Give a permissions:

sudo chmod -R 755 /var/www/virtualsites/
sudo chown -R www-data /var/www/virtualsites/

Last part activate the site:


Reload the apache service

systemctl reload apache2

Done. The virtual host is ready for use. you can test it by creating an index.html file inside the public_html folder. And also it’s possible to create many virtual hosts with this way.

bubble_chart Short Description

history_toggle_off Created: None

category Related Categories

visibility Total Read: 8