Deployment

Deployment of a Mezzanine site to production is mostly identical to deploying a regular Django site. For serving static content, Mezzanine makes full use of Django’s staticfiles app. For more information, see the Django docs for deployment and staticfiles.

Fabric

Each Mezzanine project comes bundled with utilities for deploying production Mezzanine sites, using Fabric. The provided fabfile.py contains composable commands that can be used to set up all the system-level requirements on a new Debian based system, manage each of the project-level virtual environments for initial and continuous deployments, and much more.

Server Stack

The deployed stack consists of the following components:

Note

None of the items listed above are required for deploying Mezzanine, they’re simply the components that have been chosen for use in the bundled fabfile.py. Alternatives such as Apache and MySQL will work fine, but you’ll need to take care of setting these up and deploying yourself. Consult the Django documentation for more information on using different web and database servers.

Configuration

Configurable variables are implemented in the project’s settings.py module. Here’s an example, that leverages some existing setting names:

FABRIC = {
    "SSH_USER": "", # SSH username for host deploying to
    "HOSTS": ALLOWED_HOSTS[:1], # List of hosts to deploy to (eg, first host)
    "DOMAINS": ALLOWED_HOSTS, # Domains for public site
    "REPO_URL": "ssh://hg@bitbucket.org/user/project", # Project's repo URL
    "VIRTUALENV_HOME":  "", # Absolute remote path for virtualenvs
    "PROJECT_NAME": "", # Unique identifier for project
    "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
    "SECRET_KEY": SECRET_KEY,
    "NEVERCACHE_KEY": NEVERCACHE_KEY,
}

Commands

Here’s the list of commands provided in a Mezzanine project’s fabfile.py. Consult the Fabric documentation for more information on working with these:

  • fab all - Installs everything required on a new system and deploy.
  • fab apt - Installs one or more system packages via apt.
  • fab backup - Backs up the database.
  • fab create - Create a new virtual environment for a project.
  • fab deploy - Deploy latest version of the project.
  • fab install - Installs the base system and Python requirements for the entire server.
  • fab manage - Runs a Django management command.
  • fab pip - Installs one or more Python packages within the virtual environment.
  • fab psql - Runs SQL against the project’s database.
  • fab python - Runs Python code in the project’s virtual environment, with Django loaded.
  • fab remove - Blow away the current project.
  • fab restart - Restart gunicorn worker processes for the project.
  • fab restore - Restores the database.
  • fab rollback - Reverts project state to the last deploy.
  • fab run - Runs a shell comand on the remote server.
  • fab sudo - Runs a command as sudo.

Table Of Contents

Previous topic

Multi-Tenancy

Next topic

Frequently Asked Questions

This Page