Virtual Hostings2010/06/13 |
This is the example to configure virtual hostings. Main host www.srv.world [ /var/www/html ] Virtual host www.virtual.host [ /home/fedora/public_html ] Add virtual domain name in DNS first. |
[1] | configure httpd for virtual hostings |
[root@www ~]# vi /etc/httpd/conf/httpd.conf # line 975: uncomment NameVirtualHost *:80 # bottom: add these lines <VirtualHost *:80> DocumentRoot /var/www/html ServerName www.srv.world ErrorLog logs/srv.world-error_log CustomLog logs/srv.world-access_log common </VirtualHost> # bottom: add these lines <VirtualHost *:80> DocumentRoot /home/fedora/public_html ServerName www.virtual.host ErrorLog logs/virtual.host-error_log CustomLog logs/virtual.host-access_log common </VirtualHost> [root@www ~]# /etc/rc.d/init.d/httpd restart Stopping httpd: [ OK ] Starting httpd: [ OK ] |
[2] | Access to the test page with original domain. It's OK if following page is shown. |
[3] | Create a test page for new domain. It's OK if following page is shown. |
[root@www ~]# cd /home/fedora/public_html [root@www1 public_html]# vi index.html
<html>
<body> <div style="width:100%;font-size:40px;font-weight:bold;text-align:center"> Virtual Host Test Page </div> </body> </html> |
Sponsored Link |