2013-04-17 122 views
0

试图设置虚拟主机,并确定我做错了什么。如果我运行apachectl,我得到这个警告。Mountain Lion apache vhost

$ sudo apachectl -t 
httpd: Could not reliably determine the server's fully qualified domain name, using Johns-MacBook-Pro.local for ServerName 
[Tue Apr 16 21:34:01 2013] [warn] _default_ VirtualHost overlap on port 80, the first has precedence 
Syntax OK 

所以发生了什么是一切都恢复到顶级的虚拟主机。这是我的虚拟主机文件

<VirtualHost *:80> 
    DocumentRoot "/Users/jcostanzo/development/impress" 
    ServerName impress.local 
    ServerAlias impress.local 
    ErrorLog "/private/var/log/apache2/impress.local-error_log" 

    <Directory "/Users/jcostanzo/development/impress" > 
     AllowOverride All 
     Order allow,deny 
     Allow from all 
    </Directory> 
</VirtualHost> 

<VirtualHost *:80> 
    DocumentRoot "/Users/jcostanzo/development/testsomething" 
    ServerName testing.local 
    ServerAlias testing.local 
    ErrorLog "/private/var/log/apache2/test.local-error_log" 

    <Directory "/Users/jcostanzo/development/testsomething" > 
     AllowOverride All 
     Order allow,deny 
     Allow from all 
    </Directory> 
</VirtualHost> 

回答

0

的第一个警告

httpd: Could not reliably determine the server's fully qualified domain name, using Johns-MacBook-Pro.local for ServerName 

你,因为你没有定义服务器的名字呢。在/private/etc/apache2/httpd.conf轻松地定义它:

ServerName localhost 

比你的主机名是本地主机,你将不会再收到此警告。一些更多的信息是在这里:httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

第二个警告:

[Tue Apr 16 21:34:01 2013] [warn] _default_ VirtualHost overlap on port 80, the first has precedence 

可能出现,因为你在你的虚拟主机文件丢失

NameVirtualHost *:80 

。你编辑了标准

/private/etc/apache2/extra/httpd-vhosts.conf
文件吗?这也是有点怪,你采取同样的网址为
ServerAlias
作为
ServerName
此配置,再试一次,它应该工作:

NameVirtualHost *:80 

<VirtualHost *:80> 
    ServerName impress.local 
    ServerAlias www.impress.local 
    DocumentRoot "/Users/jcostanzo/development/impress" 
    ErrorLog "/private/var/log/apache2/impress.local-error_log" 
    <Directory "/Users/jcostanzo/development/impress" > 
     AllowOverride All 
     Order allow,deny 
     Allow from all 
    </Directory> 
</VirtualHost> 

<VirtualHost *:80> 
    ServerName testing.local 
    ServerAlias www.testing.local 
    DocumentRoot "/Users/jcostanzo/development/testsomething" 
    ErrorLog "/private/var/log/apache2/test.local-error_log" 
    <Directory "/Users/jcostanzo/development/testsomething" > 
     AllowOverride All 
     Order allow,deny 
     Allow from all 
    </Directory> 
</VirtualHost> 

运行

apachectl -S
看,如果Apache接受您的配置。