Halaman Utama > Knowledgebase > Cpanel - WHM > Django with fastcgi


Django with fastcgi




Django can be installed on a shared environment if you use FastCGI with it.

In your public_html directory, add this to your file named .htaccess:

AddHandler fcgid-script .fcgi
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ mysite.fcgi/$1 [QSA,L]

Then, create a small script that tells Apache how to spawn your FastCGI program. Create a file mysite.fcgi and place it in your Web directory, and be sure to make it executable:

#!/usr/bin/env python
import os, user, sys

sys.path.insert(0, "/home/USERNAME/django/")
sys.path.insert(0, "/home/USERNAME/django/projects")
sys.path.insert(0, "/home/USERNAME/django/projects/newproject")


# Switch to the directory of your project. (Optional.)
#os.chdir("/home/USERNAME/django/projects/newproject")

# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = "newproject.settings"

from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")

The paths are assuming that the following URL was used.
http://docs.google.com/Doc?id=dhhpr5xs_463522g



Apakah Jawaban ini membantu?

Tambahkan ke Favorit Tambahkan ke Favorit    Cetak Artikel Ini Cetak Artikel Ini

Baca Juga
Proper MIME types (Dilihat: 219)
URL redirect methods (Dilihat: 243)
About reseller WHM (Dilihat: 216)

Powered by WHMCompleteSolution