我正在与我的托管服务提供商合作以启动并运行一个 Django 应用程序,但我们都没有非常有经验,而且我们基本上已经走到了完全的死胡同。
我没有直接访问 conf 文件的权限,但我是这样描述它的内容的:
<IfModule mod_wsgi.c>
WSGIScriptAlias /fredapp/ /home/fred/public_html/cgi-bin/fredapp/apache/django.wsgi
WSGIDaemonProcess fred threads=15 display-name=%{GROUP} python-path=/home/fred/public_html/cgi-bin/fredapp/apache/
WSGIProcessGroup fred
WSGIApplicationGroup %{GLOBAL}
</IfModule>
Alias /robots.txt /home/fred/public_html/fred-site/robots.txt
Alias /favicon.ico /home/fred/public_html/fred-site/favicon.ico
Alias /settings/media/ /home/fred/public_html/fred-site/media/
我的“django.wsgi”脚本没什么特别的:
import os, sys
sys.path.append('/home/fred/public_html/cgi-bin/')
sys.path.append('/home/fred/public_html/cgi-bin/fredapp/')
os.environ['DJANGO_SETTINGS_MODULE'] = 'fredapp.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
所以我的理解是,所有这一切都意味着如果对 domain.com/fredapp/ 的请求进入,它应该通过 django.wsgi 移交给应用程序。但是,我得到的唯一回应是:
[Fri Jan 22 18:46:08 2010] [error] [client xx.xxx.xx.xx] File does not exist: /home/fred/public_html/domain.com/500.shtml
[Fri Jan 22 18:46:08 2010] [error] [client xx.xxx.xx.xx] mod_wsgi (pid=26760): Exception occurred processing WSGI script '/home/fred/public_html/cgi-bin/fredapp/apache/django.wsgi'.
[Fri Jan 22 18:46:03 2010] [error] [client xx.xxx.xx.xx] File does not exist: /home/fred/public_html/domain.com/404.shtml
[Fri Jan 22 18:46:03 2010] [error] [client xx.xxx.xx.xx] File does not exist: /home/fred/public_html/domain
这是在 Linux 上的 Apache 下运行的。我尝试在服务器上的 Python 解释器中运行 .wsgi 脚本的每一行,但它们都没有返回任何错误。我也尝试了这个sys.stdout = sys.stderr
技巧,但没有得到比上面更多的输出。该文件不存在错误与站点的其余设置有关,并且在任何请求时都会发生。我还没有正确完成所有设置(错误页面和索引页面等),因为我只是想让应用程序本身运行。
我已经在我自己的机器上在 Apache 下启动并运行了这个应用程序,虽然不是在守护程序模式下,但它是我的第一个 Django 应用程序,我认为我的托管服务提供商以前从未配置过,所以我们正在飞行小盲人。如果有人有任何建议,我将不胜感激。谢谢!