0

尝试设置虚拟主机并不确定我做错了什么。如果我运行 apachectl,我会收到此警告。

$ 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>
4

1 回答 1

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

比您的主机名是 localhost 并且您不会再收到此警告。更多信息在这里:httpd:无法可靠地确定服务器的完全限定域名,使用 127.0.0.1 作为 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
文件?您使用相同的 URL 也有点奇怪
服务器别名
至于
服务器名称
使用此配置再试一次,它应该可以工作:

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 接受你的配置。

于 2013-04-21T10:23:39.533 回答