Host multiple domain name in a Virtual Host.

1. You may need to install apache in your CentOS box.

yum install httpd

2. Edit the httpd.conf file.

vi /etc/httpd/conf/httpd.conf

Below is my customize httpd.conf which host two websites (siteone.com and sitetwo.com).

Listen *:80
<VirtualHost 192.168.2.124:80>
ServerAdmin test@webserverpage.com
ServerName siteone.com
ServerAlias www.siteone.com
DocumentRoot /var/www/html/siteone
DirectoryIndex index.html index.pl index.php
DocumentRoot /var/www/html/siteone
ScriptAlias /cgi-bin/ /var/www/html/siteone/cgi-bin/
<Directory “/var/www/html/siteone/cgi-bin”>
AllowOverride None
AddHandler cgi-script .pl
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost 192.168.2.124:80>
ServerAdmin test@webserverpage.com
ServerName sitetwo.com
ServerAlias www.sitetwo.com
DocumentRoot /var/www/html/sitetwo
DirectoryIndex index.html index.php
</VirtualHost>

3. Restart apache to make it work.

service httpd restart

4. Upload your website to your specified path in your “DocumentRoot” in httpd.conf. Mine is in this location /var/www/html/siteone and /var/www/html/sitetwo

5. Done.

Leave a Reply