如何在共享主机中设置 Django 网站?我检查了django安装,没问题
>>> import django
>>> django.VERSION
>>> (1, 4, 0, 'final', 0)
我已经关注了http://www.djangobook.com/en/2.0/chapter12/部分 Running Django on a Shared-Hosting Provider with Apache 无济于事。目前网站是这样的
/home/django_projects/WebsiteName
/sites/WebsiteName.co.id/www/.htaccess
/sites/WebsiteName.co.id/www/dispatch.fcgi
.htaccess 文件是这样的
AddHandler fastcgi-script .fcgi
RewriteEngine On
RewriteBase /
RewriteRule ^(media/.*)$ $1 [QSA,L]
RewriteRule ^(admin_media/.*)$ $1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi/$1 [QSA,L]
dispatch.fcgi 是这样的
#!/usr/bin/python
import sys, os
sys.path = ['$HOME/lib/python/Django-1.4'] + sys.path
sys.path = ['$HOME/django_projects'] + sys.path
os.chdir("$HOME/django_projects")
#from flup.server.fcgi import WSGIServer
from django.core.servers.fastcgi import runfastcgi
os.environ['DJANGO_SETTINGS_MODULE'] = 'WebsiteName.settings'
runfastcgi(["method=threaded", "daemonize=false"])
当我访问该网站时,它不断生成错误 500,内部错误。到目前为止我尝试的是,
[1] Changing AddHandler fastcgi-script .fcgi to AddHandler fcgid-script .fcgi
[2] Removing AddHandler fastcgi-script .fcgi
[3] Putting the website directory to /sites/WebsiteName.co.id/www/WebsiteName instead of /home/django_projects/WebsiteName/
[4] Do no. 3 and move dispatch.fcgi to /sites/WebsiteName.co.id/www/WebsiteName
如果这个问题如此愚蠢,我很抱歉。我是 Django 的新手。顺便说一句,没有 1-4 不按顺序排列。这只是对我迄今为止尝试过的事情进行编号。另外,如果我不这样做。4、网站显示dispatch.fcgi的内容。