0

我希望你能帮忙。我有一个现有的 Apache 2.2 服务器,它为我维护的网站提供服务。我正在尝试为同事添加其他网站。这样做后,当我尝试访问 URL 时,我得到以下信息:

未找到 在此服务器上未找到请求的 URL /。

这是我的 httpd-vhosts.conf 文件的摘要。我有三个新的、大致相同的主机无法正常工作。只有 NDV 和默认值有效。

NameVirtualHost *:80

<VirtualHost anycast.ns.cs.boeing.com:80>
        ServerName anycast.ns.cs.boeing.com
        ServerAdmin aodhan.hoffman@boeing.com
        DocumentRoot "/opt/www/anycast"

        ScriptAlias /cgi-bin "/opt/www/anycast/cgi-bin/"
        ErrorLog "logs/grant_error_log"
        CustomLog "logs/grant_access_log" common
</VirtualHost>

<VirtualHost *:80>
        ServerAdmin aodhan.hoffman@boeing.com
        DocumentRoot "/opt/httpd/manual"
        ServerAlias ntpm-application-01.ns.cs.boeing.com
        ErrorLog "logs/error_log"
        CustomLog "logs/access_log" common
</VirtualHost>


<VirtualHost *:80>
        ServerAdmin aodhan.hoffman@boeing.com
        DocumentRoot "/opt/www/ndv/html"
        ServerName ndv.web.boeing.com
        ScriptAlias /cgi-bin/ "/opt/www/ndv/cgi-bin/"
        ErrorLog "logs/error_log"
        CustomLog "logs/access_log" common
</VirtualHost>

<Directory "/opt/www/ndv/html/" >
        Options Indexes FollowSymLinks Includes 
        AddType text/html .shtml
        AddOutputFilter INCLUDES .shtml 
        Order allow,deny
        Allow from all
</Directory>

<Directory "/opt/www/anycast/html/" >
        Options Indexes FollowSymLinks Includes 
        Order allow,deny
        Allow from all
</Directory>

根据上面的配置,这就是服务器所看到的。

$ sudo bin/apachectl -S

VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80                   is a NameVirtualHost
         default server ntpm-application-01.ns.cs.boeing.com (/opt/httpd/conf/extra/httpd-vhosts.conf:30)
         port 80 namevhost ntpm-application-01.ns.cs.boeing.com (/opt/httpd/conf/extra/httpd-vhosts.conf:30)
         port 80 namevhost ndv.web.boeing.com (/opt/httpd/conf/extra/httpd-vhosts.conf:39)
         port 80 namevhost anycast.ns.cs.boeing.com (/opt/httpd/conf/extra/httpd-vhosts.conf:48)
         port 80 namevhost ntpget.ns.cs.boeing.com (/opt/httpd/conf/extra/httpd-vhosts.conf:60)
         port 80 namevhost dnsdig.ns.cs.boeing.com (/opt/httpd/conf/extra/httpd-vhosts.conf:70)
Syntax OK
4

3 回答 3

2

您似乎混合了配置方法:

NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.domain.tld
ServerAlias domain.tld *.domain.tld
DocumentRoot /www/domain
</VirtualHost>

<VirtualHost *:80>
ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain
</VirtualHost>

这是 Apache Docs 关于基于名称的 VHosts 的示例。

我可以在您的配置 VirtualHost 中看到没有 * -> anycast.ns.cs.boeing.com:80

以及没有服务器名称的虚拟主机,例如 ServerAlias ntpm-application-01.ns.cs.boeing.com,它有一个别名,但没有名称。

我会开始平衡示例中的配置,然后尝试 apache 是否对此更满意。

简而言之:确保每个条目都有 *:80 和服务器名称。

编辑:此配置未经测试,但可能对您有用

NameVirtualHost *:80

<VirtualHost *:80>
        ServerName anycast.ns.cs.boeing.com

        ServerAdmin aodhan.hoffman@boeing.com
        DocumentRoot "/opt/www/anycast/html"

        ScriptAlias /cgi-bin "/opt/www/anycast/cgi-bin/"
        ErrorLog "logs/grant_error_log"
        CustomLog "logs/grant_access_log" common

        <Directory "/opt/www/anycast/html/" >
            Options Indexes FollowSymLinks Includes 
            Order allow,deny
            Allow from all
        </Directory>        
</VirtualHost>

<VirtualHost *:80>
        ServerName ntpm-application-01.ns.cs.boeing.com

        ServerAdmin aodhan.hoffman@boeing.com
        DocumentRoot "/opt/httpd/manual"

        ErrorLog "logs/error_log"
        CustomLog "logs/access_log" common
</VirtualHost>


<VirtualHost *:80>
        ServerName ndv.web.boeing.com

        ServerAdmin aodhan.hoffman@boeing.com
        DocumentRoot "/opt/www/ndv/html"

        ScriptAlias /cgi-bin/ "/opt/www/ndv/cgi-bin/"
        ErrorLog "logs/error_log"
        CustomLog "logs/access_log" common

        <Directory "/opt/www/ndv/html/" >
            Options Indexes FollowSymLinks Includes 
            AddType text/html .shtml
            AddOutputFilter INCLUDES .shtml 
            Order allow,deny
            Allow from all
        </Directory>
</VirtualHost>
于 2012-07-19T19:25:09.927 回答
0

我的建议是打开并阅读 apache 生成的所有日志。这将为您提供问题所在的线索。"/private/var/log/apache2/error_log"我在 Mac 中阅读了日志并找到了我的线索:DocumentRoot [/path/to/rootdir] does not exist.

我打开了 vhost 文件,发现我没有用双引号将根目录封装,而是使用了其他看起来像双引号的字符。我用真正的双引号替换了它们,重新启动了 apache,然后错误就消失了。

于 2015-08-21T19:33:25.867 回答
0

对我有用的是卸载和升级(在我的情况下为 Wampserver)您正在使用的软件。

于 2021-11-14T17:41:49.460 回答