This site has been retired. For up to date information, see handbook.gnome.org or gitlab.gnome.org.


[Home] [TitleIndex] [WordIndex

1. Setting Up Snowy on DreamHost

1.1. Introduction

This guide is for installing Snowy in a shared hosting environment like DreamHost, where you must install your own Python, Django, and other dependencies locally. It is geared toward using FastCGI and Apache, and is based on http://wiki.dreamhost.com/Django , so please read that if anything here seems off.

1.2. Assumptions In This Guide

You can of course deviate from any of these, but here are the assumptions I'm making as I write this guide:

1.3. Setup

In a typical DreamHost setup, the first thing you need to do is install Python 2.6 and many modules in your home directory. In this example, we will use $HOME as the installation prefix (so install files will end up in ~/bin/, ~/lib, ~/share, etc). Before installing anything, it is probably easiest to modify your .bash_profile like so:

export PATH=$HOME/bin:$PATH
export PYTHONPATH=$HOME/django-projects:$HOME:$PYTHONPATH

The second line implies that we are going to install Snowy to ~/django-projects/snowy.

The first time after creating this, you'll need to run source ~/.bash_profile.

Now we have various tarballs we need to download and install to have an appropriate Python environment, starting with Python 2.6. Here's what I installed...I do not remember the order, but it was probably something like:

TODO: Test this again on a fresh dreamhost user/domain to record exact steps

Sorry for the lack of details at this time, but I'm guessing I did something like the following (after extracting all the tarballs to ~/tarballs):

cd ~/tarballs/Python-2.6.2 && ./configure --prefix=~ && make && make install
cd ~/tarballs/setuptools-0.6c9 && sh setuptools-0.6c9-py2.4.egg --prefix=~
cd ~/tarballs
easy_install MySQL-python-1.2.3c1
easy_install python-dateutil-1.4.1
easy_install pytz-2009j
easy_install libxml2-python-2.6.21
easy_install pysqlite-2.5.5
easy_install Django-1.1

Okay, now in theory you have a sufficiently prepared environment. Please double-check that the python command loads a Python 2.6 console. If it doesn't, add alias python=python2.6 to ~/.bash_profile.

Lastly, to set up the admin media properly:

ln -s $HOME/tarballs/Django-1.1/django/contrib/admin/media $HOME/media.mydomain.com/admin_media

1.4. Setting up FastCGI

cd ~/mydomain.com
wget http://svn.saddi.com/py-lib/trunk/fcgi.py

Then create the file ~/mydomain.com/dispatch.fcgi with the following contents:

import sys
sys.path = ['/home/YOURDREAMHOSTUSERNAME','/home/YOURDREAMHOSTUSERNAME/django-projects','/home/YOURDREAMHOSTUSERNAME/django-projects/snowy'] + sys.path
from fcgi import WSGIServer
from django.core.handlers.wsgi import WSGIHandler
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'snowy.settings'
WSGIServer(WSGIHandler()).run()

Set up permissions:

chmod 755 ~/mydomain.com/dispatch.fcgi ~/mydomain.com/fcgi.py

Edit ~/mydomain.com/.htaccess :

RewriteEngine On
RewriteBase /
RewriteRule ^(dispatch\.fcgi/.*)$ - [L]
RewriteRule ^(.*)$ dispatch.fcgi/$1 [L]

Note that if you are putting your install in a subdirectory like ~/mydomain.com/snowy , you will edit ~/mydomain.com/snow/.htaccess, and RewriteBase should be set to /snowy, not /.

1.5. Setting up Snowy

I recommend getting Snowy from git. This allows you to see any changes you've made to your local checkout (and maybe send them back to us as patches). Also, you can switch to any arbitrary version for testing purposes. Upgrading to a new release could be as easy as git pull --rebase && git checkout SNOWY_1_2 (for example).

cd ~/django-projects
git clone git://git.gnome.org/snowy
cd snowy
cat INSTALL  # Yes, you really should read this ;-)

I don't want to repeat the contents of INSTALL here, since then I'd have to maintain two documents. ;-) Read them and follow them. Just don't run python manage.py runserver , and when you're ready to admin your install, go to http://mydomain.com/admin . Here is my local_settings.py (in this example I'm using sqlite:

# Local Django settings for snowy project.

DEBUG = True
TEMPLATE_DEBUG = DEBUG

DATABASE_ENGINE = 'sqlite3'    # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = '/home/YOURDREAMHOSTUSERNAME/django-projects/snowy/snowy.db'

ADMIN_MEDIA_PREFIX = 'http://media.mydomain.com/admin_media/'

DEFAULT_FROM_EMAIL = 'registration@mydomain.com'

# Fill in this information from
# http://recaptcha.net/api/getkey?app=snowy
RECAPTCHA_ENABLED = False
RECAPTCHA_PUBLIC_KEY = ''
RECAPTCHA_PRIVATE_KEY = ''

Make sure to:

chmod 600 local_settings.py

If for some reason you really are using sqlite, please make sure that you put the .db file somewhere inaccessible to your web users.


2024-10-23 10:59