Question

Deploying Django Mezzanine Using Fabric

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 example.com.

First Problem

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

$ supervisorctl update gunicorn_jaredrovny_app ->

[45.55.255.108] out: sudo password:
[45.55.255.108] out: error: <class 'socket.error'>, [Errno 2] No such file or directory: file: /usr/lib/python2.7/socket.py 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: 'gunicorn.conf.py' 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 local_settings.py file to have the following:

ALLOWED_HOSTS = ["<example.com>"]

and

FABRIC = {
    "DEPLOY_TOOL": "git",  # Deploy with "git", "hg", or "rsync"
    "SSH_USER": "<usr>",  # VPS SSH username
    "HOSTS": ["<IP address>"],  # The IP address of your VPS
    "DOMAINS": ALLOWED_HOSTS,  # Edit domains in ALLOWED_HOSTS
    "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>",
    "SECRET_KEY": SECRET_KEY,
    "NEVERCACHE_KEY": NEVERCACHE_KEY,
}

Highlighted regions are things I’ve changed.

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

Any ideas what’s going on here?

Show comments

Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Accepted Answer

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
exit
nano /etc/ssh/sshd_config
<change "allow root access" from "yes" to "no">
service ssh restart
logout

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/local_settings.py 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!)

FABRIC = {
    "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
    "DOMAINS": ALLOWED_HOSTS,  # Edit domains in ALLOWED_HOSTS
    "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
    "SECRET_KEY": SECRET_KEY,
    "NEVERCACHE_KEY": NEVERCACHE_KEY,
}

5 And that’s it! Make sure to navigate back to the folder with your fabric.py 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.

Hi

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.

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.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel