Installing Mezzanine on Webfaction with Apache and WSGI

When I first created MobilePebbles , the Mobile Theme Generator was installed on the primary domain. I soon decided to place the generator on a sub-domain and install Mezzanine on the primary. The site is hosted by Webfaction. Although Webfaction has install scripts for quite a few apps (Drupal, Django, etc), they do not currently have one for Mezzanine. But, without too much trouble (thanks to the tools that are availed to Webfaction customers), I was able to install Mezzanine on Webfaction.

Much of the information in this post I found by installing Mezzanine On Ubuntu (and from documentation that I found in Webfactions docs.

Note: A couple of years ago, I transferred most of my websites to Hosting with Webfaction has been a wonderful experience. They live up to their tag: “Hosting For Developers”.

Installed Python Version

First, find which versions of Python are installed.

ls /usr/local/bin/ | grep python

The following is the result of the above command on my account:


Alternatively, you can look in your $HOME/lib folder, but this can be misleading because, for my set up, python2.5 was the latest folder that was created. I initially tried to set up Mezzanine under python2.5, but received a few errors due to certain commands not being recognized.

I want to use python2.7, because that is the version that I’m using on my local computer. Because python2.5 is the latest version in the $HOME/lib folder, I created a new folder.

mkdir lib/python2.7

Before we install Mezzanine, let’s add a python alias that points to the python2.7 folder. Open up $HOME/.bash_profile (vi .bash_profile:

alias python=python2.7 #or whatever version you are using

Now when you enter use the python command, your server will always point to the version of python that you are using.

We will use eazy_install command to install the Mezzanine package under the latest version of Python installed. So if python2.7 installed, type the command:

easy_install-2.7 mezzanine

Create mod_wsgi app

Now we need to create a mod_wsgi app from Webfaction’s Control Panel. If you have not created a domain within the Control Panel, please do so before preceding with this step.

Select the domain. Click Add application.
Name: mezzanine_cms
App Category: mod_wsgi
Type: mod_wsgi 3.4/Python 2.7 (or whichever version of python is on the server)

Create Mezzanine Project

Now go back to your ssh connection.

cd webapps/mezzanine_cms
mezzanine-project mysite
$ cd mysite

Create The Database

First create a PostgreSql database using Webfaction’s control panel. Remember the name and the password.

By default, Mezzanine creates sqlite database. I want to use a PostgreSql database, so I edited the Mezzanine settings file (/webapps/mezzanine_cms/

cd /webapps/mezzanine_cms
    "default": { 
        "ENGINE": "django.db.backends.postgresql_psycopg2", 
        # DB name or path to database file if using sqlite3. 
        "NAME": "mezzanine_cms", 
        "USER": "yourusername", 
        "PASSWORD": "yourpassword", 
        # Set to empty string for localhost. Not used with sqlite3. 
        "HOST": "", 
        # Set to empty string for default. Not used with sqlite3. 
        "PORT": "", 

Now create the Mezzanine database.

python createdb --noinput

Updating Apache config

When we created our default mod_wsgi 3.4/Python 2.7 application, the document root location was to /webapps/mezzanine_cms/htdocs. We need to change it to point to /webapps/mezzanine_cms/mysite.

vi /webapps/mezzanine_cms/apache2/conf/httpd.conf

Your updated file should look similar to this:

ServerRoot "/home/<username>/webapps/mezzanine_cms/apache2" 
LoadModule dir_module        modules/ 
LoadModule env_module        modules/ 
LoadModule log_config_module modules/ 
LoadModule mime_module       modules/ 
LoadModule rewrite_module    modules/ 
LoadModule setenvif_module   modules/ 
LoadModule wsgi_module       modules/ 
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined 
CustomLog /home/<username>/logs/user/access_mezzanine_cms.log combined 
#remove Directory index and DocumentRoot
#DocumentRoot /home/<username>/webapps/mezzanine_cms/mysite 
ErrorLog /home/<username>/logs/user/error_mezzanine_cms.log 
KeepAlive Off 
Listen 26857 
MaxSpareThreads 3 
MinSpareThreads 1 
ServerLimit 1 
SetEnvIf X-Forwarded-SSL on HTTPS=1 
ThreadsPerChild 5 
# Be sure to include your app (i.e, mysite) to your python path.
WSGIDaemonProcess mezzanine_cms processes=5 python-path=/home/<username>/webapps/mezzanine_cms:/home/<username>/webapps/mezzanine_cms/mysite:/home/<username>/webapps/mezzanine_cms/lib/python2.7 threads=1 
WSGIProcessGroup mezzanine_cms 
WSGIRestrictEmbedded On 
WSGILazyInitialization On 
#add this line. It should point to your wsgi script.
WSGIScriptAlias / /home/<username>/webapps/mezzanine_cms/mysite/ 
#remove this
#<Directory /home/<username>/webapps/mezzanine_cms/mysite> 
#    AddHandler wsgi-script .py 

Now restart Apache


You should be able to view your site.

Be Sociable, Share!

Checkout My New Site - T-shirts For Geeks