2013-04-17 166 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接受您的配置。