LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Apache 2 httpd virtual hosts not working (https://www.linuxquestions.org/questions/linux-server-73/apache-2-httpd-virtual-hosts-not-working-778615/)

erics_acvw 12-29-2009 12:39 AM

Apache 2 httpd virtual hosts not working
 
Hi,

I am running CentOS 5.4 and Apache 2.2.3 straight out of the box. Problem is vhosts will not work. All I can get is a test page or the manual. The machine I am accessing from has the hosts file edited to point test.loc to 192.168.1.254 on my LAN. Owner:group are apache:apache, same as the server is running and permissions include read by owner. No errors in the logs. Any suggestions?

httpd.conf
<VirtualHost _default_:*>
DocumentRoot /var/www/apache/manual
# DocumentRoot /var/www/eswebs
</VirtualHost>

NameVirtualHost *:80

<VirtualHost *:80>
ServerName test.loc
ServerAlias test.com www.test.com test.loc www.test.loc
DocumentRoot /var/www/test
ServerAdmin me@some.com
ErrorLog logs/error_log
CustomLog logs/access_log combined
</VirtualHost>
============

Spill from -S command line option:
[root@server httpd]# httpd -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
_default_:8443 69.109.23.9 (/etc/httpd/conf.d/nss.conf:73)
_default_:443 69.109.23.9 (/etc/httpd/conf.d/ssl.conf:81)
_default_:* 69.109.23.9 (/etc/httpd/conf/httpd.conf:995)
*:80 is a NameVirtualHost
default server test.com (/etc/httpd/conf/httpd.conf:4)
port 80 namevhost eswebs.com (/etc/httpd/conf/httpd.conf:4)
Syntax OK

bathory 12-29-2009 03:09 AM

You don't need the <VirtualHost _default_:*> for the vhost on port 80
Quote:

default server test.com (/etc/httpd/conf/httpd.conf:4)
port 80 namevhost eswebs.com (/etc/httpd/conf/httpd.conf:4)
Check httpd.conf, because from the above it looks like the default vhost is test.com (it should be test.loc) and the 1st vhost is eswebs.com (?).

ashwin_cse 12-29-2009 03:14 AM

In the httpd.conf comment out these lines :
<VirtualHost _default_:*>
DocumentRoot /var/www/apache/manual
# DocumentRoot /var/www/eswebs
</VirtualHost>

NameVirtualHost *:80

and make sure this is the only virtual host section you have:
<VirtualHost *:80>
ServerName test.loc
ServerAlias test.com www.test.com test.loc www.test.loc
DocumentRoot /var/www/test
ServerAdmin me@some.com
ErrorLog logs/error_log
CustomLog logs/access_log combined
</VirtualHost>

and it will work.


All times are GMT -5. The time now is 05:27 AM.