【发布时间】:2014-10-24 11:36:56
【问题描述】:
我正在尝试检查我的主机是否支持我的 django 站点所需的内容,因此 atm 我正在尝试设置一个基本的 django 站点。 使这更加复杂的是我需要从同一台服务器上运行另一个 joomla 页面(见下文)。 我不知道我是否做错了什么(很可能)以及我应该向主持人询问什么。 (我知道我在这方面有点菜鸟)
这是我目前所拥有的: 在 /home/username/
-
library-site/
- lib/
- manage.py
- lib/
- settings.py
- ...
- lib/
-
公共-html/
- cgi-bin
- 文件夹包含_joomla_site
- 图书馆
-
库
- bin
- ...
(按照指南,我已将 virtualenv 的站点包符号链接到 library_site/lib)
我不得不说我已经尝试了很多指南,所以很难展示整个图片,但这是我现在所拥有的
在 public_html/library/dispatch.fcgi 中
#!/home/username/library/bin/python
import sys
import os
sys.path.insert(0, "/home/username/library/bin/python")
sys.path.append('/home/username/library/lib/python2.6/site-packages')
sys.path.insert(13, "/home/username/public_html/library")
open("/home/username/public_html/library/cgi.log", "w").write("Before try")
try:
os.environ['DJANGO_SETTINGS_MODULE'] = 'lib.settings'
from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")
except Exception:
open("/home/username/public_html/library/cgi.log", "w").write(format_exc())
raise
在 public_html/library/.htaccess 中
AddHandler fcgid-script .fcgi
Options +FollowSymLinks
RewriteEngine On
RewriteBase /library/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(dispatch\.fcgi/.*)$ - [L]
RewriteRule ^(.*)$ dispatch.fcgi/$1 [L]
像这样导航到http://example.com/library 会显示文件夹的内容。点击dispatch.fcgi只显示python代码。
从 ./dispatch.fcgi 运行返回正确的 django 输出,但前四行读取
WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI!
WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!
WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!
WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!
这些都告诉我,我需要向主人询问一些事情,但我现在不知道什么。
还有,正在运行
python ~/library_site/lib/manage.py runfcgi daemonize=false host=127.0.0.1 port=3033 maxrequests=1
这里推荐:https://twiki.cern.ch/twiki/bin/view/ITCF/DjangoGeneral 不会返回任何问题。
最后,启动 django 服务器:
python manage.py runserver 0.0.0.0:8000
工作正常。有人可以帮忙吗?
【问题讨论】:
-
您确定您的服务器尊重 .htaccess 吗?必须专门启用它,并且您的 URL 似乎根本没有被重写。
标签: python django .htaccess fastcgi