Deploying Django Mezzanine Using Fabric

Posted August 25, 2016 5.3k views
DjangoDeploymentUbuntu 16.04

I’m trying to use a “fab all” (or “fab install”, “fab deploy”) to get Django Mezzanine up on Ubuntu. Even being as vanilla as I can, I get errors. At best, no errors are thrown, and I just get the nginx splash page at my IP with nothing at my

First Problem

Running “fab all” or “fab deploy” raises this error:

$ supervisorctl update gunicorn_jaredrovny_app ->

[] out: sudo password:
[] out: error: <class 'socket.error'>, [Errno 2] No such file or directory: file: /usr/lib/python2.7/ line: 228

After tracking this problem to supervisorctl, I’ve found that a “sudo service supervisor start” on the server allows getting past the above. But the site still won’t deploy, so I’ve included the above because I’m not sure what role it’s playing in my problems…

Second Problem

After searching around, I found my “/home/usr/logs/<mezz_app>_supervisor” log shows

Error: '' doesn't exist

I cannot find out why this is happening.

With a local virtualenv, mezzanine, etc., the only thing I do before “fab all” is edit my file to have the following:



    "DEPLOY_TOOL": "git",  # Deploy with "git", "hg", or "rsync"
    "SSH_USER": "<usr>",  # VPS SSH username
    "HOSTS": ["<IP address>"],  # The IP address of your VPS
    "REQUIREMENTS_PATH": "requirements.txt",  # Project's pip requirements
    "GUNICORN_PORT": 8000, # Port gunicorn will listen on
    "LOCALE": "en_US.UTF-8",  # Should end with ".UTF-8"
    "DB_PASS": "",  # Live database password
    "ADMIN_PASS": "",  # Live admin user password
    "REPO_URL": "<github url>",

Highlighted regions are things I’ve changed.

(FYI, I’ve tried things like putting “.postgresql_psycopg2” in the DATABASES section, changing the file, and a handful of other things as well, including explicitly moving the “missing” file to the directory where it’s being looked for– still nothing!)

Any ideas what’s going on here?

1 comment
  • Followup note:
    Problem “1” above doesn’t occur on Ubuntu 14.04.5, but problem “2” (‘’ doesn’t exist) persists.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
3 answers

I think I’ve got it! With all the things I changed, I think the only important difference was including a virtual environment path in the local settings file (VIRTUALENV HOME). But below is the full process in case anyone is struggling.

Pretend my username is bob.

1 I got a fresh Ubuntu 14 (NOT 16!) Digital Ocean Server.
2 Set up the server by hand with the following steps (instead of using “fab secure”. Probably doesn’t matter). Summarized from a Digital Ocean article (don’t remember where).

ssh root@[ip-address]
adduser bob
gpasswd -a bob sudo
su - bob
mkdir .ssh
chmod 700 .ssh
nano .ssh/authorized_keys
<insert public key from your own computer>
chmod 600 .ssh/authorized_keys
nano /etc/ssh/sshd_config
<change "allow root access" from "yes" to "no">
service ssh restart

I don’t think you’ll need back on the server any more.

3 I’m running OSX locally. Installed pip and virtualenv, made an environment, and got mezzanine and fabric (note, if you’re running anaconda python or something, the virtualenv might get confused about your directories).

virtualenv mezzanine_env
cd mezzanine_env
source bin/activate
pip install mezzanine fabric
mezzanine-project bobs_project
cd bobs_project

At this point (still in the project directory) I set up my git repository. Plenty of tutorials out there about that, I think.

4 Edit the /bobs_project/ file. I didn’t edit any other files but this one! When I was done, it looked like this (note that I included the virtual environment path!)

    "DEPLOY_TOOL": "git",  # Deploy with "git", "hg", or "rsync"
    "SSH_USER": "bob",  # VPS SSH username
    "VIRTUALENV_HOME": "/home/bob", # Absolute remote path for virtualenvs
    "HOSTS": ["<ip-address>"],  # The IP address of your VPS
    "REQUIREMENTS_PATH": "requirements.txt",  # Project's pip requirements
    "LOCALE": "en_US.UTF-8",  # Should end with ".UTF-8"
    "DB_PASS": "default",  # Live database password
    "GUNICORN_PORT": 8000, # Port gunicorn will listen on
    "ADMIN_PASS": "default",  # Live admin user password

5 And that’s it! Make sure to navigate back to the folder with your file in it, then

fab all

and follow the prompts / provide passwords.

Hope this helped!

P.S. I think the mezzanine CMS login starts as username: admin, password: default.

Thank you for the article, however I keep on running into the same problem over and over again. fab all or fab secure keeps asking for the password of the user without doing anything else. I have done about 10 vanilla installs on both debain and ubuntu with exactly the same results. Any help would be appreciated.

  • I spent 4 hours on the same issue yesterday.
    The problem is that basically when you do fab secure it creates a new user and adds that user the the sudoers file, which is all well and good. Then, it changes PermitRootAccess in /etc/ssh/sshd_config from yes to no!! This is your issue. Fix it and everything will work fine.

    Make sure you do service ssh restart after you change the file.


Thank you for the answer, pity that I’ve given up on Mezzanine a long time ago.

Nevertheless, at least it is now solved for other users.