2015-05-28 36 views
2

我在Windows上,並試圖在Apache服務器上調用mod_wsgi。我找到了/usr/lib/apache2/modules/中的mod_wsgi.so,我有一個名爲MyApp的目錄 - /home/danu_bg/public_html/MyAppHello World使用mod_wsgi,內部錯誤,配置錯誤

在這個目錄中我有application.wsgi

def application(environ, start_response): 
    status = '200 OK' 
    output = 'Hello World!' 

    response_headers = [('Content-type', 'text/plain'), 
         ('Content-Length', str(len(output)))] 
    start_response(status, response_headers) 

    return [output] 

而且.htaccess配置文件是

<Directory /home/danu_bg/public_html/MyApp> 
WSGIScriptAlias /home/danu_bg/public_html/MyApp/application.wsgi 
Order allow,deny 
Allow from all 
</Directory> 

我不認爲我可以訪問主配置文件,httpd.config當我看着我/usr/lib/apache2/buildconfig.nice但看不到httpd.config

我正在使用WinSCP連接到服務器,我沒有shell訪問權限。 當我去到URL,我得到這個錯誤

Internal Server Error 
The server encountered an internal error or misconfiguration and was unable to complete your request 
+0

您不能將Directory/WSGIScriptAlias放在.htaccess文件中。只有mod_wsgi.so在系統上是不夠的,Apache必須被配置爲加載它。您確實需要從主機提供者那裏瞭解Apache是​​否配置爲加載mod_wsgi。如果它是一個共享系統,他們不應該允許您使用.htaccess文件中的mod_wsgi,因爲這樣做會帶來安全風險,除非他們已採取特殊措施來配置mod_wsgi以將應用程序隔離到自己的進程。 –

回答

0

當我看網頁https://code.google.com/p/modwsgi/wiki/ConfigurationDirectives

我看到了WSGIScriptAlias指令的語​​法如下:

WSGIScriptAlias /name /web/wsgi-scripts/name 

所以指令需要兩個參數:URI和wsgi腳本。你的情況可能是這樣的:

WSGIScriptAlias /應用/public_html/MyApp/application.wsgi

揭露/應用URL提交的申請。

+0

嗨Freek,我編輯了答案,包括我已經使用的完整路徑 – gbhrea