Talk:Mezzanine

This guide actually comes from [Moosechip]. I just updated it for the most recent version of virtualenv and some changes on how static files are generated.

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.9.1.tar.gz   tar xzf virtualenv-1.9.1.tar.gz    python virtualenv-1.9.1/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 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 and site_media

cd ~/site.com/mez python ./manage.py collectstatic ln -s ~/site.com/mez/static ~/site.com/public/static mkdir site_media 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