Code


Version 1 (modified by Chris Moffitt <chris.moffitt@…>, 7 years ago) (diff)

Initial draft of thinkhost install

Setting up Django on Thinkhost

Control Panel Setup

  • Use the Thinkhost control panel to make sure that fcgi is enabled on your domain.
Manage Domains -> Domain.com -> Edit -> Enable Fast-CGI: Enable
  • Use the control panel to create your MySQL username and password as well as any databases you may want to use.

Command Line Configuration

  • ssh into your account
  • Create a directory to store Django
cd my-domain.com
mkdir tools
cd tools
  • Checkout the latest version of django into the tools directory
svn co http://code.djangoproject.com/svn/django/trunk/ django_src
  • Create a directory for flup and checkout the latest source into the tools directory
svn co http://svn.saddi.com/flup/trunk flup

  • Create ~/my-domain.com/cgi-bin/mysite.fcgi as shown below. Make sure to put in the correct paths.
#!/usr/local/bin/python
import sys, os

# Add a custom Python path.
sys.path.insert(0, "/usr/home/www/yourusername/my-domain.com/tools/django_src")
sys.path.insert(0, "/usr/home/www/yourusername/my-domain.com/tools/flup")
# Switch to the directory of your project. (Optional.)
os.chdir("/usr/home/www/yourusername/my-domain.com/tools/yourproject")

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

from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")
  • Create ~/my-domain.com/docs/.htaccess as shown below.
AddHandler fastcgi-script .fcgi
RewriteEngine On
RewriteRule ^/(media.*)$ /$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(shop.*)$ /cgi-bin/mysite.fcgi/$1 [QSA,L]
RewriteRule ^(admin.*)$ /cgi-bin/mysite.fcgi/$1 [QSA,L]
  • Create links to the admin media directory so the data will be served up when we go to the admin site.
ln -s /usr/home/www/yourusername/my-domain.com/tools/django_src/django/contrib/admin/media