Apache 无法访问 Django 应用程序
所以这是设置:
如果我删除应用程序(其名称 是 myapp) 在设置文件的 INSTALLED_APPS 部分中我在 apache2.conf 中添加了 WSGIPythonHome
我可以通过 Django 中的交互式 python shell (python manage.py shell
) 成功访问应用程序。我可以创建、更新和删除数据。
我正在使用 Ubuntu 10.04 Lucid Lynx 的标准 Apache 2 设置(启用站点、启用 mods、apache2.conf 等)
我正在运行位于 /home/ygamretuta/dev/myproject 的 virtualenv
我的 django 项目位于 / home/ygamretuta/dev/site1
错误日志文件显示此内容(最后 2 行):
File "/home/ygamretuta/dev/myproject/lib/python2.6/site-packages/django/utils/importlib.py", line 35, in import_module
TemplateSyntaxError: Caught ImportError while rendering: No module named myapp
我的 django.wsgi 包含此内容:
import os, sys
sys.path.append('/home/ygamretuta/dev')
os.environ['DJANGO_SETTINGS_MODULE'] = 'site1.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
我的 site1.com 虚拟主机文件(包含在站点可用文件夹中)包含此内容(删除了其他详细信息) :
WSGIDaemonProcess ygamretuta processes=2 maximum-requests=500 threads=1
WSGIProcessGroup ygamretuta
WSGIScriptAlias / /home/ygamretuta/dev/site1/apache/django.wsgi
我可能错过了什么?如果未注释掉自定义应用程序(我使用 manage.py startapp 制作的应用程序),我将收到 e 500 内部服务器错误
so here's the setting:
The whole site is working fine if I remove the application (whose name
is myapp) in the INSTALLED_APPS section in the settings file I added WSGIPythonHome in apache2.conf
I can successfully access the apps via the the interactive python shell in Django (python manage.py shell
). I can create, update and delete data.
I am using the standard Apache 2 setup for Ubuntu 10.04 Lucid Lynx(sites-enabled, mods-enabled, apache2.conf, etc)
I am running a virtualenv located in /home/ygamretuta/dev/myproject
My django project is located in /home/ygamretuta/dev/site1
error Log file says this (last 2 lines):
File "/home/ygamretuta/dev/myproject/lib/python2.6/site-packages/django/utils/importlib.py", line 35, in import_module
TemplateSyntaxError: Caught ImportError while rendering: No module named myapp
my django.wsgi contains this:
import os, sys
sys.path.append('/home/ygamretuta/dev')
os.environ['DJANGO_SETTINGS_MODULE'] = 'site1.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
my virtual host file for site1.com (contained in the sites-available folder) contains this (stripped of other details):
WSGIDaemonProcess ygamretuta processes=2 maximum-requests=500 threads=1
WSGIProcessGroup ygamretuta
WSGIScriptAlias / /home/ygamretuta/dev/site1/apache/django.wsgi
What could I have missed? I am getting e 500 Internal Server Error if the custom apps (the ones I made with manage.py startapp) are not commented out
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将
/home/ygamretuta/dev/site1
附加到sys.path
。Append
/home/ygamretuta/dev/site1
tosys.path
.