Search code examples
djangowebfactionmezzanine

How to install Mezzanine on Webfaction Server


I've been choosing a django CMS for my personal site, and I decided that Mezzanine would be the one that most satisfies my needs. But I find it impossible for me to install it on Webfaction. There's all kinds of errors going on, and for a noob like me it's very frustrating. I followed this awesome guide, http://ijcdigital.com/blog/installing-django-mezzanine-at-webfaction/, which is probably written a year ago. Unfortunately, I simply can't get it working by following that guide. So could anyone provide me a more up-to-date and easy to follow guide for installing Mezzanine on Webfaction?

Thanks very much.


Solution

  • To install Mezzanine on a WebFaction hosting account, first create a new PostgreSQL database via the WF control panel, and make a note of the database name and password.

    Next, create a "Django 1.6.10 (mod_wsgi 3.5/Python 2.7)" application and assign it to a website.

    Next, SSH into your server and run the following commands (replacing name_of_your_app, database_name, database_password, and my_cms with appropriate values):

    mkdir -p ~/lib/python2.7
    easy_install-2.7 pip
    cd ~/webapps/name_of_your_app
    export PYTHONPATH=$PWD/lib/python2.7
    pip2.7 install -U --install-option="--install-scripts=$PWD/bin" --install-option="--install-lib=$PWD/lib/python2.7" mezzanine
    ~/bin/mezzanine-project my_cms
    cd my_cms
    sed -i 's/"ENGINE": "django.db.backends.sqlite3"/"ENGINE": "django.db.backends.postgresql_psycopg2"/g' local_settings.py
    sed -i 's/"NAME": "dev.db"/"NAME": "database_name"/g' local_settings.py
    sed -i 's/"USER": ""/"USER": "database_name"/g' local_settings.py
    sed -i 's/"PASSWORD": ""/"PASSWORD": "database_password"/g' local_settings.py
    sed -i 's/DEBUG = True/DEBUG = False/g' local_settings.py
    echo "ALLOWED_HOSTS = ['yourdomain.com',]" >> local_settings.py
    python2.7 manage.py createdb --noinput
    python2.7 manage.py collectstatic --noinput
    sed -i 's/myproject\/myproject\/wsgi.py/my_cms\/wsgi.py/g' ../apache2/conf/httpd.conf
    sed -i 's/myproject/my_cms/g' ../apache2/conf/httpd.conf
    ../apache2/bin/restart
    

    Next, create a "Symbolic link to static-only app" in the control panel, using "/home/your_username/webapps/name_of_your_app/my_cms/static" as the symlink path (in the "extra info" field, then assign that app to your site, using '/static' as the URL path.

    Then just wait a few minutes for that last change to gel, and you're done.