Deploying Mezzanine to Digital Ocean using the included fabfile

The process

  1. Sign up for Digital Ocean (that's a referral link which you are in no way obligated to use)
  2. Create a droplet (I've added my SSH key to Digital Ocean so I assign that to the droplet). I used Debian 7 x64
  3. Point your domain's A record at the IP address Digital Ocean assigns to your droplet.
  4. Log into the vps as root, create a new user and give it sudo permission, $ adduser new_user_name then $ visudo
  5. In visudo find the line root ALL=(ALL:ALL) ALL replicate it just below and replace root with the username created above.
  6. In your local project copy the default fabric dictionary from settings.py to local_settings.py and uncomment it
  7. Fill in the fabric settings
  8. Configure ALLOWED_HOSTS in deploy/live_settings.py, i.e., ALLOWED_HOSTS = ['example.com']
  9. Open your project's requirements.txt and add pillow to a new line (This should get automatically installed by Mezzanine but for some reason isn't)
  10. Run fabric $ fab all
  11. Go to your site in your browser

Notes

Log locations

Logs end up in /var/log/ particularly:

  • nginx: /var/log/nginx
  • supervisor: /var/log/supervisor

The supervisor directory contains logs of gunicorn's stderr and stdout which would include Django errors.

Example project

The project I deployed is here, it's just vanilla Mezzanine with ALLOWED_HOSTS set and pillow added to the requirements

Example fabric dictionary

FABRIC = {
    "SSH_USER": "do", # SSH username
    "SSH_PASS":  "", # SSH password (consider key-based authentication)
    "SSH_KEY_PATH":  "/Users/josh/.ssh/id_rsa.pub", # Local path to SSH key file, for key-based auth
    "HOSTS": ['do.bitpl.us'], # List of hosts to deploy to
    "VIRTUALENV_HOME":  "/home/do", # Absolute remote path for virtualenvs
    "PROJECT_NAME": "do_test", # Unique identifier for project
    "REQUIREMENTS_PATH": "requirements.txt", # Path to pip requirements, relative to project
    "GUNICORN_PORT": 8000, # Port gunicorn will listen on
    "LOCALE": "en_US.UTF-8", # Should end with ".UTF-8"
    "LIVE_HOSTNAME": "do.bitpl.us", # Host for public site.
    "REPO_URL": "https://[email protected]/joshcartme/vanilla_mezz", # Git or Mercurial remote repo URL for the project
    "DB_PASS": "abc123", # Live database password
    "ADMIN_PASS": "abc123", # Live admin user password
    "SECRET_KEY": SECRET_KEY,
    "NEVERCACHE_KEY": NEVERCACHE_KEY,
}

Comments