Installing Mezzanine on Webfaction with Apache and WSGI

Mezzanine Templates and Styling

Although your site is viewable, there is no styling. First we are going to run the collecttemplates command to copy of Mezzanine’s template files to your project’s templates folder.

cd /home/<username>/webapps/mezzanine_cms/mysite
python collecttemplates

Check your templates folder, to make sure that the files are there. Now we’ll run the collectstatic to copy all static files (css, images, js, etc) to your project’s static folder.

Python collectstatic --link --noinput

The –link option tells the command to create a symbolic link. The –noinput option is so that you won’t get prompted for any input.
Now view your site. Still no styles. If you view the source the page, you will see:

<link rel="stylesheet" href="/static/css/bootstrap.css">
<link rel="stylesheet" href="/static/css/mezzanine.css">
<link rel="stylesheet" href="/static/css/bootstrap-responsive.css">

The browser is looking for the CSS files under the static folder, but Apache does not know that the folder exists, so it can’t serve to the files. So let’s update Apache config.

vi /home/<username>/webapps/mezzanine_cms/apache2/conf/httpd.conf

The commented portions are the changes.

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/ 
#add these modules
LoadModule alias_module      modules/ 
LoadModule authz_host_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 
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 
#add the aliases
AliasMatch ^/([^/]*\.css) /home/<username>/webapps/mezzanine_cms/mysite/css/$1 
Alias /robots.txt /home/<username>/webapps/mezzanine_cms/mysite/static/robots.txt 
Alias /favicon.ico /home/<username>/webapps/mezzanine_cms/mysite/static/favicon.ico 
Alias /media/ /home/<username>/webapps/mezzanine_cms/mysite/media/ 
Alias /static/ /home/<username>/webapps/mezzanine_cms/mysite/static/ 
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 
WSGIScriptAlias / /home/<username>/webapps/mezzanine_cms/mysite/ 
#add the directories
<Directory /home/<username>/webapps/mezzanine_cms/mysite/static> 
    Order deny,allow 
    Allow from all 
<Directory /home/<username>/webapps/mezzanine_cms/mysite/media> 
    Order deny,allow 
    Allow from all 

I created an alias for static and media. These files will be served by Apache.

Note: I also created aliases for robots.txt and favicon.ico. For more information, view Django’s documentation.

Now restart Apache.


Now view your site. That’s it. You should now have Apache, Wsgi, and Mezzanine working on your Webfaction-served website.

Note: You probably don’t want to change Mezzanine’s template and CSS files, so you should create an Django app, copy the template and css files into the app, and update those files only. In my previous post, I discuss how this is done. Enjoy.

Be Sociable, Share!

Checkout My New Site - T-shirts For Geeks