我正在使用 Centos6.3,并且使用以下配置 apache切片主机教程。
我的配置如下:
<VirtualHost *:80>
ServerName christabellehotel.com
ServerAlias www.christabellehotel.com
DirectoryIndex index.php
DocumentRoot /home/sites/christabellehotel.com
LogLevel warn
ErrorLog /home/sites/christabellehotel.com/error.log
CustomLog /home/sites/christabellehotel.com/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName akteabeach.com
ServerAlias www.akteabeach.com
DirectoryIndex index.php
DocumentRoot /home/sites/akteabeach.com
LogLevel warn
ErrorLog /home/sites/akteabeach.com/error.log
CustomLog /home/sites/akteabeach.com/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName 198.199.125.69
DirectoryIndex index.php
DocumentRoot /home/sites/
LogLevel warn
ErrorLog /home/sites/error.log
CustomLog /home/sites/access.log combined
</VirtualHost>
问题是当我打开http://christabellehotel.com/我看不到我配置的虚拟主机,如下所示:http://198.199.125.69/christabellehotel.com
有用信息:
# /usr/sbin/httpd -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
_default_:443 198.199.125.69 (/etc/httpd/conf.d/ssl.conf:74)
*:80 is a NameVirtualHost
default server christabellehotel.com (/etc/httpd/conf/httpd.conf:1023)
port 80 namevhost christabellehotel.com (/etc/httpd/conf/httpd.conf:1023)
alias www.christabellehotel.com
port 80 namevhost akteabeach.com (/etc/httpd/conf/httpd.conf:1034)
alias www.akteabeach.com
port 80 namevhost 198.199.125.69 (/etc/httpd/conf/httpd.conf:1044)
语法正确
答案1
取出第三个虚拟主机条目,将其移至顶部,并将指令更改为
<VirtualHost 198.199.125.69:80>
答案2
改成NameVirtualHost *:80
NameVirtualHost *