2012-07-19 80 views
0

我希望你能幫上忙。我有一個現有的Apache 2.2服務器,它服務於我維護的網站。我正在嘗試爲一位同事添加更多網站。完成後,當我嘗試訪問URL時,我收到以下內容:Apache 2.2 VirtualHosts URL not found

未找到請求的URL /在此服務器上未找到。

下面是我的httpd-vhosts.conf文件的摘要。我有三個新的,大致相同的主機不工作。只有NDV和默認正在工作。

NameVirtualHost *:80 

<VirtualHost anycast.ns.cs.boeing.com:80> 
     ServerName anycast.ns.cs.boeing.com 
     ServerAdmin [email protected] 
     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 [email protected] 
     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 [email protected] 
     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 

回答

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的文檔就基於域名虛擬主機的例子。

我可以在你的配置虛擬主機看不* - > anycast.ns.cs.boeing.com:80

以及虛擬主機,而不喜歡ServerAlias ntpm-應用01.ns.cs服務器名稱.boeing.com 它有一個別名,但沒有名字。

我會開始平衡例子中的配置,然後嘗試如果Apache更加滿意。

總之:確保每個條目都有*:80和一個服務器名稱。

編輯:此配置未經測試,但可能爲你工作

NameVirtualHost *:80 

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

     ServerAdmin [email protected] 
     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 [email protected] 
     DocumentRoot "/opt/httpd/manual" 

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


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

     ServerAdmin [email protected] 
     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> 
+0

謝謝,我平衡了配置,它現在看起來像這樣但行爲沒有不同。 ndv仍然有效,但任播只是返回'URL not found'。由於我有索引,我期望看到一個自動索引,但它只是說'/'沒有找到。它令人驚歎。 – oddhan 2012-07-19 19:56:58

+0

謝謝,但行爲沒有不同。 NameVirtualHost *:80 ServerName anycast.domain.com ServerAdmin [email protected]。COM 的DocumentRoot 「/選擇/網絡/泛播」 的ScriptAlias /的cgi-bin 「的/ opt/WWW /任播/的cgi-bin /」 錯誤日誌 「日誌/ grant_error_log」 的CustomLog 「日誌/ grant_access_log」 共同 <目錄 「的/ opt/WWW /播/ HTML /」> 選項指標包括了FollowSymLinks令 允許,拒絕 所有 – oddhan 2012-07-19 19:58:43

+0

嚴正允許,只是我發現。引號真的可以在apache配置中工作嗎?我從來沒有見過。 – 2012-07-19 20:59:43

0

我的建議是打開並閱讀所有的Apache生成的日誌。這會給你一個線索,說明問題出在哪裏。我在MAC讀取日誌在"/private/var/log/apache2/error_log",發現我的線索:DocumentRoot [/path/to/rootdir] does not exist.

我打開虛擬主機文件,並發現,而不是在雙引號封裝根目錄下我使用的好像雙引號其他字符。我用真正的雙引號取代了它們,重啓了apache,然後錯誤消失了。