Here’s some notes for installing Mezzanine on Dreamhost using virtualenv. This can be useful for installing on any server where you don’t have permissions to install python packages normally. There’s also notes here for how to set up Passenger to serve your site via Apache.
In Dreamhost panel, setup site for use with Passenger & ssh
Ssh into your Dreamhost server
Setup a Python virtualenv so you can install your own Python packages. Check the virtualenv pypi page for the latest virtualenv version (currently 1.6.3).
wget http://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.6.3.tar.gz tar xzf virtualenv-1.6.3.tar.gz python virtualenv-1.6.3/virtualenv.py $HOME/local rm -rf virtualenv* export PATH=$HOME/local/bin:$PATH
You probably want to add $HOME/local/bin to your path permanently. Add the export line to your ~/.bashrc file:
export PATH=$HOME/local/bin:$PATH
To make sure that you are using the virtualenv python, check that which python returns /home/youruser/local/bin/python and NOT /usr/bin/python.
Now you can install some Python packages
pip install --upgrade django mezzanine south paste
Create a mezzanine project
cd ~/site.com # Name this project whatever you like. I will use "mez" mezzanine-project mez
Edit your settings in mez/local_settings.py. I will leave the sqlite database for testing. You could should probably create a mysql database for a real site though. Add these lines so Django knows where files are.
TIME_ZONE = 'America/Los_Angeles' APP_URL = 'http://site.com' ## Note the leading and trailing slash here #ADMIN_MEDIA_PREFIX = '/admin_media/' #MEDIA_ROOT= '/home/youruser/site.com/mez/site_media/' #MEDIA_URL = 'http://site.com/site_media'
Setup your site with Passenger by creating a ~/site.com/passenger_wsgi.py file with the following:
import sys,os # Force Passenger to run our virtualenv python INTERP = "/home/youruser/local/bin/python" if sys.executable != INTERP: os.execl(INTERP, INTERP, *sys.argv) # Setup paths and environment variables sys.path.append("/home/youruser/site.com") sys.path.append("/home/youruser/site.com/mez") os.environ['DJANGO_SETTINGS_MODULE'] = 'mez.settings' # Set the application import django.core.handlers.wsgi from paste.exceptions.errormiddleware import ErrorMiddleware application = django.core.handlers.wsgi.WSGIHandler() # Use paste to display errors application = ErrorMiddleware(application, debug=True)
Now setup the static files
ln -s ~/site.com/mez/site_media ~/site.com/public/site_media
Setup the database
cd ~/site.com/mez python manage.py syncdb # I think I initially had some errors running migrate, # but it worked the second time running migrate python manage.py migrate
Restart the web server. Ordinarily you might do sudo /etc/init.d/apache2 restart. On Dreamhost you do this by touching tmp/restart.txt. (If the tmp directory doesn’t exist, mkdir ~/site.com/tmp)
touch ~/site.com/tmp/restart.txt
That should be it. Check to see if your site is up and running.
TODO’s: setup mysql, customize theme, etc
There’s alternative ways to handle the static files. The package django-staticfiles might be better? I haven’t tried it.