[英]deploying django application on Apache using mod_wsgi
使用mod_wsgi在Apache HTTP服務器上部署Django應用程序時遇到一些問題。 我已將信息添加到httpd.conf(WSGIScriptAlias)中,該信息指示文件wsgi.py以及測試內容:
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]
當我運行它時,一切似乎都還可以,因為我可以看到“ Hello world!”。 但是,當我將文件wsgi.py更改為此時:
import os
import sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
我有:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
wsgi.py文件與settings.py文件位於同一目錄...(我的所有應用程序都位於子目錄中:mydomain / public_html / hc / hc / hc / settings.py-hc是我的應用程序的名稱)
有什么事嗎 我應該怎么做才能使我的應用正常工作? 如何找出導致錯誤的原因?
sys.path.append('path_to_python_dir')
sys.path.append('path_to_project')
將這些行添加到wsgi.py文件中。
settings.py中的問題也會導致500錯誤。
我自己解決了我的問題,添加了此幫助(在導入后):
sys.path.append('path_to_project')
sys.path.append('path_to_wsgi_py_file')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.