2017-04-16 301 views
0

我遇到一個問題,在Apache的設置WSGIScriptAlias,在嘗試使用別名在試圖達到「字面」 URL給一個404錯誤。下面是測試設置在我的Apache2 sites-available/000-default.conf(模仿mod_wsgi Quick Start Guide):爲什麼WSGIScriptAlias沒有效果?

DocumentRoot /var/www/html 
WSGIScriptAlias /wsgi_test /var/www/html/test.wsgi 
<Directory /var/www/html> 
     Order allow,deny 
     Allow from all 
</Directory> 

重新啓動的Apache2和去mydomain.com/wsgi_test後,會顯示一個404錯誤頁面。下面Apache的error.log文件的第一行顯示服務器試圖訪問DocumentRoot URL路徑wsgi_test,而不是別名文件路徑:

AH00128: File does not exist: /var/www/html/wsgi_test 
AH01964: Connection to child 1 established (server nathanclonts.com:443) 
(70007)The timeout specified has expired: [client 67.161.148.188:33883] AH01991: SSL input filter read failed. 

文件/var/www/html/test.wsgi具有相同的代碼作爲上述快速入門指南:

def application(environ, start_response): 
    status = '200 OK' 
    output = b'Hello World!' 
    response_headers = [('Content-type', 'text/plain'), 
        ('Content-Length', str(len(output)))] 
    start_response(status, response_headers) 
    return [output] 

由於權限設置爲:

-rwxrw-r-- 1 username www-data 278 Apr 16 11:31 test.wsgi 

沒有人有意見在哪裏尋找其他可能影響此配置的配置,或其他任何調試技巧?

有什麼奇怪的是,我已經設置了當前在同一個虛擬主機工作mod_wsgi的另一個(Django的)應用程序,但顯然我錯過了在本次測試的東西。

+1

Django配置相對於您添加的內容定義在哪裏?如果Django應用程序是在路徑「/」,那麼你在這裏補充必須在此之前,其他的「/」爲Django應用程序匹配的將優先考慮。 –

+0

事實證明,這只是一個與一般的別名配置的問題:[WSGIScript]別名是爲定義'虛擬主機*',而不是'虛擬主機*:433'(服務器使用SSL)。將它們添加到'VirtualHost *:433文件修復它。感謝您的建議,但要記住好! – Nathan

回答

0

這是通過更新所述<VirtualHost *:443>配置文件以包括WSGIScriptAlias線(作爲服務器使用SSL)解決,而不是<VirtualHost *>配置下具有WSGIScriptAlias

我不知道,所有的別名需要被包含在443端口的功能,但最終與香草Alias和定位哪些文件,他們在玩定義後的工作了:

grep -R "Alias" /etc/apache2/*