Apache vitual host issue
Hello Friends .
i have install apache in my RHEL5.6 . # yum install httpd After installing Apache i run the httpd service by. # yum restart httpd than i check the default page in Firefox and elinks it worked properly. than i put a simple website index.html in the default document root /var/www/html/. restart the httpd service and it worked fine in the bowsers. i tried to configure a name based virtualhost here is the configuration . Code:
After making this configuration i restarted the httpd service again. Now the problem is here. Now when i test these configuration in the browser , I typed localhost in the browser now the index.html of the localhost machine is not showing now. The index.html page of sports.com is coming instead of localhost's index.com . ## I have added the sports.com in the /etc/hosts/ file in the line of 127.0.0.1 after localhost 127.0.0.1 localhost localhost.localdomain sports.com #### Now where is the problem ... Kindly help me in this. Thanks and regards Md Reza |
Your problem is right in your post. Review the NameVirtualHost directive. This will map the virtual host you follow it with to the IP address you specify. So your *:80 NameVirtualhost line is going to serve the next virtualhost(your sports.com vhost) as the one for all the IPs on the system, including localhost. Remove that line and it will not serve the sports.com content on the localhost host name or any of the IPs directly.
|
Code:
# this doesn't look right to me |
Now i posted the new configuration code .. still getting the same error...
Kindly help me. |
the document root in your httpd.conf should be :/var/www/vhosts/sports.com/html/ since this is where you put the index.html
|
Hi,
After configuring any virtual host, Apache only honor virtual hosts in order they appear in the configuration files. So in order to still avail your default web page, you need to also define an additional virtual host for it. Something as: Code:
<VirtualHost *:80> |
Quote:
|
Thanks you very much for making me understand about this concept.
|
All times are GMT -5. The time now is 06:08 AM. |