报错信息1:

Starting httpd: [Fri May 19 11:49:42 2006] [warn] VirtualHost 127.0.0.1:80 overl
aps with VirtualHost 127.0.0.1:80, the first has precedence, perhaps you need a
NameVirtualHost directive

这个说明虚拟主机的NAME没开,NameVirtualHost 就是他没开,如下就可以了

#加上这里就好了~~,之后就可加任意多的virtual host了

NameVirtualHost 192.168.8.37:80
#
# NOTE: NameVirtualHost cannot be used without a port specifier
# (e.g. :80) if mod_ssl is being used, due to the nature of the
# SSL protocol.
#

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
#<VirtualHost *:80>
#     ServerAdmin webmaster@dummy-host.example.com
#     DocumentRoot /www/docs/dummy-host.example.com
#     ServerName dummy-host.example.com
#     ErrorLog logs/dummy-host.example.com-error_log
#     CustomLog logs/dummy-host.example.com-access_log common
#/VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot /var/www/html
ServerName dummy-host.example.com
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>

<VirtualHost 192.168.8.37:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot /var/www/html
ServerName XXX.com
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>

http://hi.baidu.com/xingyuanju/blog/item/87f6b85008f832648435246b.html

修改完成后,通过 apachectl -t 检查语法格式的问题,并通过apachectl -S 检查虚拟主机的相关配置;
如果配置正确将得到类似以下信息
default server www.myhome.com (/home/http/conf/httpd.conf:??)
port * namevhost www.myhome.com (/home/http/conf/httpd.conf:??)
port * namevhost acer.myhome.com (/home/http/conf/httpd.conf:??)
Syntax OK

使用

service apache2 restart

apachectl restart

重启Apache

附apachectl参  数:
configtest 检查设置文件中的语法是否正确。
fullstatus 显示服务器完整的状态信息。
graceful 重新启动Apache服务器,但不会中断原有的连接。
help 显示帮助信息。
restart 重新启动Apache服务器。
start 启动Apache服务器。
status 显示服务器摘要的状态信息。
stop 停止Apache服务器。

http://blog.csdn.net/fcoolx/archive/2008/04/15/2294668.aspx

Published in Linux

No Responses to “the first has precedence, perhaps you need a NameVirtualHost directive”

Leave a Reply

请输入算式结果(看不清请点击图片)
(必须)