【问题标题】:Mountain Lion apache vhost山狮 apache 虚拟主机
【发布时间】:2013-04-09 14:57:29
【问题描述】:

尝试设置虚拟主机并不确定我做错了什么。如果我运行 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>

【问题讨论】:

    标签: apache osx-mountain-lion


    【解决方案1】:

    第一个警告

    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: 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
    相同的 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是​​否接受您的配置。

    【讨论】:

      猜你喜欢
      • 2011-06-19
      • 2019-08-25
      • 2012-04-26
      • 2012-09-25
      • 2011-03-25
      • 2018-06-26
      • 1970-01-01
      • 2011-05-04
      • 2011-11-04
      相关资源
      最近更新 更多