Virtual Hosting with Apache Linux Server

How to Setup Multiple Hosts on Apache

It's the example to configure virtual hostings. Following example is done as domain name[server.world (root directory[/var/www/html])], virtual domain name[virtual.host (root directory[/home/cent/public_html])]. Before doing it, it's necessarry to add new doman name in your DNS first.

  1. Configure httpd for Virtual Hostings.

 [root@www ~]# vi /etc/httpd/conf/httpd.conf
# line 990: uncomment

NameVirtualHost *:80
# at the last lines: ( for original domain )


   DocumentRoot /var/www/html
   ServerName www.server.world

# at the last lines: ( for virtual domain )


   DocumentRoot /home/cent/public_html
   ServerName www.virtual.host
   ServerAdmin [email protected]
   ErrorLog logs/virtual.host-error_log
   CustomLog logs/virtual.host-access_log combined

[root@www ~]# /etc/rc.d/init.d/httpd restart

Stopping httpd:[  OK  ]

Starting httpd:[  OK  ]

  1. Access to the test page that is for original domain, it's OK if possible


www.yourlink.com

  1. Access to the test page that is for virtual domain, it's OK if possible.


 [cent@www ~]$vi ./public_html/index.cgi

#!/usr/local/bin/perl

print "Content-type: text/html\n\n";
print "\n\n";
print "
\n"; print "Virtual Host Test Page"; print "\n
\n"; print "\n\n"; [cent@www ~]$ chmod 705 ./public_html/index.cgi


Windows VPS HOsting 
  • 26 Users Found This Useful
Was this answer helpful?

Related Articles

Cheapest Linux VPS Hosting in the world!

Access the best web hosting vps to enhance the efficiencyWeb hosting is an obligatory service if...

Install MySQL for Database Server on CentOS VPS

 Install MySQL for Database Server. [root@www ~]# yum -y install mysql-server...

Add a HardDrive to Your Linux VPS

 This is an example to create a partition when you add a new hard drive. root@dlp:~#...

HowTo: Shrink size of ext4 LVM logical volume

HowTo: Shrink size of ext4 LVM logical volume LVM, the Logical Volume Manager, is...

HowTo: Extend size of ext4 LVM logical volume

How to Manage and Use LVM (Logical Volume Management) in Ubuntu In...