我知道这可能是一个经常被问到的问题,但我尽了最大的努力来启动我的第一个 django 网站,但没有任何结果,所以请任何有共享主机和 django 经验的人帮忙。以下是任何相关信息:python 2.6 安装在远程机器上 $HOME/.local/lib/flup 和 django 在同一个地方,所有这些都是由 setup.py install --user 完成的。我的 django 项目文件结构:
$HOME/
projects/django/bw_python/
manage.py
bw_python/
__init__.py
settings.py
urls.py
wsgi.py
site_main/
django app with urls,models, etc...
在 $HOME/.bashrc 我有以下几行:
export PATH=$HOME/.local/bin:$HOME/.local/usr/bin:$PATH
export PYTHONPATH=$HOME/projects/django:$HOME/projects/django/bw_python:$HOME/projects/django/bw_python/bw_python:$HOME/projects/django/bw_python/site_main:$PYTHONPATH
如果我运行 python 解释器 django 并且 Flup 正在运行,则 manage.py runserver 可以正常工作。
现在在 public_html 我有以下 bw_python.fcgi 脚本:
#!/usr/bin/env python
import sys, os
# Add a custom Python path.
sys.path.insert(0, "/home5/bwinnova/.local/lib/python")
# Switch to the directory of your project. (Optional.)
os.chdir("/home5/bwinnova/projects/django/bw_python")
# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = "bw_python.settings"
from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")
如果我执行 ./bw_python.fcgi 我得到:
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!
Status: 301 MOVED PERMANENTLY
Content-Type: text/html; charset=utf-8
Location: http://localhost/home/
.htaccess:
AddHandler fcgid-script .fcgi
RewriteEngine On
RewriteCond %{REQUEST_URI} !-f
RewriteRule ^(.*)$ bw_python.fcgi/$1 [QSA,L]
这两个文件(包括 $HOME/projects/django/bw_python)上的 chmod 是 755。对不起,但是从教程中我被困在这里?下一步要做什么?我总是收到 500 服务器错误,在服务器错误日志中只有这样:
[Fri Jul 27 19:29:14 2012] [warn] RewriteCond: NoCase option for non-regex pattern '-f' is not supported and will be ignored.
在此先感谢您提供的任何帮助或指导。