簡體   English   中英

找不到 Apache 2.2 VirtualHosts URL

[英]Apache 2.2 VirtualHosts URL not found

我希望你能幫忙。 我有一個現有的 Apache 2.2 服務器,它為我維護的網站提供服務。 我正在嘗試為同事添加其他網站。 這樣做后,當我嘗試訪問 URL 時,我得到以下信息:

Not Found 請求的 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

您似乎混合配置方法:

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關於基於名稱的VHost的示例。

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

以及沒有像ServerAlias ntpm-application-01.ns.cs.boeing.com這樣的服務器名稱的VHost,它有一個別名但沒有名字。

我會開始平衡配置中的配置,然后嘗試ap​​ache對此更滿意。

簡而言之:確保每個條目都有*: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>

我的建議是打開並讀取apache生成的所有日志。 這將為您提供問題所在的線索。 我在mac中讀取了"/private/var/log/apache2/error_log"中的"/private/var/log/apache2/error_log" ,發現了我的線索: DocumentRoot [/path/to/rootdir] does not exist.

我打開了vhost文件,發現不是用雙引號封裝根目錄,而是使用了其他似乎是雙引號的字符。 我用真正的雙引號替換它們,重新啟動apache然后錯誤消失了。

對我有用的是卸載和升級(在我的情況下為 Wampserver)您正在使用的軟件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM