2012-02-28 52 views
2

運行Django的時我已經在運行Apache的Django當一個問題:錯誤:目標WSGI腳本找不到或無法統計在Apache

的htdocs /博客/應用/主頁/ urls.py:

url(r'^$', 'index', name="h_index"), 
url(r'^about/$', 'about', name="h_about"), 
url(r'^contact/$', 'contact', name="h_contact"), 
url(r'^archive/$', 'archive', name="h_archive"), 

的htdocs /博客/ urls.py

(r'^', include('apps.homepage.urls')), 

django.wsgi:

import os 
import os.path 
import sys 

sys.path.append('D:/Coding/xampp/htdocs') 
sys.path.append('D:/Coding/xampp/htdocs/blog') 

os.environ['DJANGO_SETTINGS_MODULE'] = 'blog.settings' 

import django.core.handlers.wsgi 
application = django.core.handlers.wsgi.WSGIHandler() 

的httpd.conf:

Alias /static/ "D:/Coding/xampp/htdocs/blog/static/" 
WSGIScriptAlias /blog/ "D:/Coding/xampp/htdocs/blog/django.wsgi" 
當我運行 「本地主機/博客」

,它的工作。但是,運行「本地主機/博客/約/」或其他,它的錯誤:

[error] [client ::1] Target WSGI script not found or unable to stat: .../htdocs/blog/django.wsgiabout, referer: http://localhost/blog/ 

回答

12

請注意您的apache配置與mod_wsgi的WSGIScriptAlias的記錄語法不匹配。

WSGIScriptAlias /blog/ "D:/Coding/xampp/htdocs/blog/django.wsgi"

應該是:

WSGIScriptAlias /blog "D:/Coding/xampp/htdocs/blog/django.wsgi"

(第二個符號通知後沒有尾隨的斜槓 「/博客」)

我剛剛解決了同樣的問題,只是現在發現這個線程谷歌搜索。希望這可以幫助你和未來的用戶。

欲瞭解更多信息:

-2

我會懷疑你是不是加載WSGI模塊。如果仔細看看錯誤消息,Apache會將其視爲一個文件,並將其添加到它所查找的wsgi腳本文件的名稱中 - 因此它找不到它。

+0

WSGI模塊? LoadModule wsgi_module modules/mod_wsgi.so – rocky 2012-02-29 09:44:47

相關問題