Install Apache2 with below command.
#sudo apt-get install Apache2
Create Demo VirtualHost Directory
#sudo mkdir -p /var/www/html/example.com
#sudo mkdir -p /var/www/html/theitideas.com
Create Demo Pages for Each Virtual Host
#nano /var/www/html/example.com/index.html
Paste Below code in index.html file
<html>
<head>
<title>Welcome to Example.com!</title>
</head>
<body>
<h1>It works! Example.com</h1>
</body>
</html>
Save the file and exit.
Now for theitideas.com
#nano /var/www/html/theitideas.com/index.html
Paste Below code in index.html file
<html>
<head>
<title>Welcome to theitideas.com!</title>
</head>
<body>
<h1>It works! theitideas.com</h1>
</body>
</html>
Save the file and exit.
Now Create the First Virtual Host File
#sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.com.conf
Edit the file with below command and edit file as mentioned below.
#sudo nano /etc/apache2/sites-available/example.com.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/html/example.com
</VirtualHost>
Again to the same process for theitideas.com VH.
#sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/theitideas.com.conf
Edit the file with below command and edit file as mentioned below.
#sudo nano /etc/apache2/sites-available/theitideas.com.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName theitideas.com
ServerAlias www.theitideas.com
DocumentRoot /var/www/html/theitideas.com
</VirtualHost>
Now Turn to enable both Virtual Host
#sudo a2ensite theitideas.com.conf
#sudo a2ensite theitideas.com.conf
Restart Apache Service
#sudo service apache2 restart
or
#sudo /etc/init.d/apache2 restart
Virtual Host is set in apache server. Now you have to make changes in your machine to check Virtual Machine.
#sudo nano /etc/hosts
Add line in you hosts file.
your IP example.com
your IP theitideas.com
e.g.
192.168.0.101 example.com
192.168.0.101 theitideas.com
Save and exit. Now Open your browser and open example.com and theitideas.com
#sudo apt-get install Apache2
Create Demo VirtualHost Directory
#sudo mkdir -p /var/www/html/example.com
#sudo mkdir -p /var/www/html/theitideas.com
Create Demo Pages for Each Virtual Host
#nano /var/www/html/example.com/index.html
Paste Below code in index.html file
<html>
<head>
<title>Welcome to Example.com!</title>
</head>
<body>
<h1>It works! Example.com</h1>
</body>
</html>
Save the file and exit.
Now for theitideas.com
#nano /var/www/html/theitideas.com/index.html
Paste Below code in index.html file
<html>
<head>
<title>Welcome to theitideas.com!</title>
</head>
<body>
<h1>It works! theitideas.com</h1>
</body>
</html>
Save the file and exit.
Now Create the First Virtual Host File
#sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.com.conf
Edit the file with below command and edit file as mentioned below.
#sudo nano /etc/apache2/sites-available/example.com.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/html/example.com
</VirtualHost>
Again to the same process for theitideas.com VH.
#sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/theitideas.com.conf
Edit the file with below command and edit file as mentioned below.
#sudo nano /etc/apache2/sites-available/theitideas.com.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName theitideas.com
ServerAlias www.theitideas.com
DocumentRoot /var/www/html/theitideas.com
</VirtualHost>
Now Turn to enable both Virtual Host
#sudo a2ensite theitideas.com.conf
#sudo a2ensite theitideas.com.conf
Restart Apache Service
#sudo service apache2 restart
or
#sudo /etc/init.d/apache2 restart
Virtual Host is set in apache server. Now you have to make changes in your machine to check Virtual Machine.
#sudo nano /etc/hosts
Add line in you hosts file.
your IP example.com
your IP theitideas.com
e.g.
192.168.0.101 example.com
192.168.0.101 theitideas.com
Save and exit. Now Open your browser and open example.com and theitideas.com