Hostwinds Tutorials

Search results for:

Table of Contents

You will need:
Setting up the Postgresql user
Setting up Mezzanine
Deploying the application using uWSGI
NGINX configuration

Install and Configure Mezzanine (Ubuntu 19.10)

Tags: Ubuntu 

You will need:
Setting up the Postgresql user
Setting up Mezzanine
Deploying the application using uWSGI
NGINX configuration

Mezzanine is a Content Management system written in Python. It's a great alternative to the popular WordPress and offers a similar interface.

You will need:

  • A Hostwinds SSD Cloud or Dedicated Server
  • Ubuntu 19.10. You can get the ISO from Canonical here: Then, use our guide for installing from an ISO here:
  • A working public domain. Hostwinds offers domains here:
  • Python3
  • The virtualenvwrapper script
  • Nginx Webserver
  • Postgresql

To get all of this running, use the command:

sudo apt install python3 python3-pip postgresql nginx libpq-dev

Then, use pip in install virtualenvwrapper*:

sudo pip3 install virtualenvwrapper

Normally, it's a bad idea to use pip3 in install software, but virtualenvwrapper is one of the few packages that it makes sense to install system-wide.

Now, set up an environment for the mezzanine and install it:

mkvirtualenv my_site
work on my_site
pip3 install mezzanine uwsgi pillow

With all the dependencies installed, we need to set up the database.

Setting up the Postgresql user

Configuring a user for PostgreSQL requires onlt a few SQL statements you8 can run from the SQL command line. to start the SQL shell:

sudo su postgres -c psql

In the psql shell, run these 3 lines:

CREATE USER your_site_name WITH ENCRPYPTED PASSWORD 'secure_pass';
CREATE DATABASE your_site_name;
GRANT ALL PRIVILEGES ON DATABASE your_site_name TO your_site_name;

These commands will create a database and user interact with it.

Now, we may need to grant access to that user. Use this command to edit the pg_hba.conf, that's what PostgreSQL uses to verify access:

sudo nano /etc/PostgreSQL/11/main/pg_hba.conf

Make sure this line is present in the file:

host all md5

Once you've edited the file, restart the database to apply the changes:

sudo systemctl restart postgresql

Setting up Mezzanine

Now that the database is set up, we can move on to configuring the Mezzanine. To start a Mezzanine project, use the command:

(my_site) mezzanine-project my_site

cd my site

In the my_site directory, you'll find another directory called "my_site." You'll need to edit a file called

nano mysite/

There are two things to set up in that file.

Database configuration, use the same user and passwords from the SQL user we created earlier:

"default": {
    # Add "postgresql", "mysql", "sqlite3" or "oracle".
    "ENGINE": "django.db.backends.postgresql",
    # DB name or path to database file if using sqlite3.
    "NAME": "my_site",
    # Not used with sqlite3.
    "USER": "my_site",
    # Not used with sqlite3.
    "PASSWORD": "secure_pass",
    # Set to empty string for localhost. Not used with sqlite3.
    "HOST": "",
    # Set to empty string for default. Not used with sqlite3.
    "PORT": "",

Allowed hosts:

ALLOWED_HOSTS = ['', '']

Once those are ready, save the file.

The aptly named script is used to set up and manage your server. Now that Mezzanine has the database user properly configured, we can add the tables using the createdb command like so:

python createdb

Then, add an admin user to help manage your site:

python createsuperuser

Finally, build the assets, like javascript and CSS, using:

python collectstatic

Deploying the application using uWSGI

For our website to come up, you'll need to configure a Python loader to run the code and a webserver to communicate with the outside world. Let's start with the Python loader. For this setup, we'll use the uWSGI runner.

In your my_site/my_site directory, create a file called my_site.ini, using nano:

socket =
chdir = /home/$USER/my_site
wsgi-file = my_site/
processes = 2
threads = 1

You can set up uWSGI to run at boot by creating a service file in /usr/lib/systmd/system/my_site.service:

Description=My Site

ExecStart=/home/$USER/.virtualenvs/mezzanine/bin/uwsgi my_site.ini

Finally, run the command:

sudo systemctl enable my_site


sudo systemctl start my_site

That will configure your python runner to start on boot and start it right now.

NGINX configuration

One last task to round all of this out: set up the webserver. NGINX is a popular choice for python projects because of its reverse proxy capabilities.

To configure it, add this file into /etc/Nginx/sites-enabled:

upstream mezzanine {

server {
        listen 80 default_server;
        charset utf-8;
        client_max_body_size 50M;

        location /media {
                alias /home/$USER/my_site/media;

        location /static {
                alias /home/$USER/my_site/static;

        location / {
                uwsgi_pass mezzanine;
                include uwsgi_params;

Then to apply this configuration, run the command:

sudo systemctl restart nginx

Written by Hostwinds Team  /  December 2, 2019