Published January 25, 2018 by

Run Multiple Websites on Single Server (Apache) - Name Based Virtual Host

Using Apache Name Based Virtual host we can run multiple websites on a single server.
Point your both domains to your server's public IP.

In order to configure name-based virtual hosting, you have to set the IP address on which you are going to receive the Apache requests for all the desired websites.  You can do this by NameVirutalHost directive within the Apache configuration file /etc/httpd/conf/httpd.conf file.

File excerpt: /etc/httpd/conf/httpd.conf

<VirtualHost 192.168.0.30:80>
ServerAdmin webmaster@serverkaka1.com
DocumentRoot /var/www/html/serverkaka1     
ServerName www.serverkaka1.com
</VirtualHost>

<VirtualHost 192.168.0.30:80>
ServerAdmin admin@serverkaka2.com
DocumentRoot /var/www/html/serverkaka2
ServerName www.serverkaka2.com
</VirtualHost>

Now, Restart Apache and Test.

# service httpd restart