一个共享的主机设置Django的网站 [英] Setting up Django website on a shared hosting

查看:142
本文介绍了一个共享的主机设置Django的网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你怎么安装在一个共享的主机Django的网站?
我检查Django的安装,它是确定

How do you setup a Django website in a shared hosting? I've checked the django installation and it is ok

>>> import django
>>> django.VERSION
>>> (1, 4, 0, 'final', 0)

我已经按照 http://www.djangobook.com/en/2.0/chapter12 / 部分上与Apache共享主机提供商无济于事运行Django。目前,该网站是这样的。

I've followed http://www.djangobook.com/en/2.0/chapter12/ section Running Django on a Shared-Hosting Provider with Apache to no avail. Currently the website is like this

/home/django_projects/WebsiteName
/sites/WebsiteName.co.id/www/.htaccess
/sites/WebsiteName.co.id/www/dispatch.fcgi

.htaccess文件是这样的

The .htaccess file is like this

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是这样的。

and the dispatch.fcgi is like this

#!/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,内部错误,当我访问该网站。我试了一下,到目前为止是,

It keeps generating error 500, Internal Error when I access the website. What I tried so far are,

[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的内容。

I'm sorry if this question is so foolish. I'm new to Django. Btw, no 1-4 is not in order. It's just to number what things I've tried so far. Also if I do no. 4, the website shows the content of dispatch.fcgi.

推荐答案

这是更容易部署与共享主机的mod_wsgi。我在 Quijost 的工作,我们使用nginx的作为后端下的mod_wsgi提供了一个内置的包装使用Django 1.4和Python 2.7。
我们写了<一个href=\"http://quijost.com/foro/desarrollo-web/ejemplo-de-prueba-index-py-para-django-y-mysql-con-mod_wgsi/\"相对=nofollow>在我们的mod_wsgi的论坛和小教程也许这是与你的FastCGI的例子是有用的。

It is more easy deploying with mod_wsgi on shared hosting. I work on Quijost and we offer a built-in package with Django 1.4 and Python 2.7 under mod_wsgi using nginx as backend. We wrote a small tutorial in our forums for mod_wsgi and maybe it is useful for your example with fastcgi.

这篇关于一个共享的主机设置Django的网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆