0% found this document useful (0 votes)
49 views

Cai Dat Server Linux

The document provides instructions for configuring virtual hosting on an Apache web server in CentOS 6. It describes editing the httpd.conf file to uncomment the NameVirtualHost directive and add VirtualHost sections for the original "www.server.world" and virtual "www.virtual.host" domains. It also shows how to create a test CGI script for the virtual host and check that pages can be accessed for both the original and virtual domains.

Uploaded by

Shift Del
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

Cai Dat Server Linux

The document provides instructions for configuring virtual hosting on an Apache web server in CentOS 6. It describes editing the httpd.conf file to uncomment the NameVirtualHost directive and add VirtualHost sections for the original "www.server.world" and virtual "www.virtual.host" domains. It also shows how to create a test CGI script for the virtual host and check that pages can be accessed for both the original and virtual domains.

Uploaded by

Shift Del
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

http://www.server-world.info/en/note?

os=CentOS_6&p=httpd&f=6

1. Virtual hosting:
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 )

<VirtualHost *:80> DocumentRoot /var/www/html ServerName www.server.world </VirtualHost> # at the last lines: ( for virtual domain )

<VirtualHost *:80> 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 </VirtualHost> [root@www ~]# /etc/rc.d/init.d/httpd restart

Stopping httpd: [ OK ]

Starting httpd: [ OK ]

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

[3] 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 "<html>\n<body>\n"; print "<div style=\"width: 100%; font-size: 40px; font-weight: bold; text-align: center;\">\n"; print "Virtual Host Test Page"; print "\n</div>\n"; print "</body>\n</html>\n";

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

You might also like