Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Deployment instructions

Manger-Veggie is a regular Django project without any special cases, therefor those are standard deployment instruction for the nginx/supervisord/git/virtualenv/Django stack.

Create a new user

In root:

adduser mangerveggie
# fill blank informations and no password

Get the code

apt-get install git python-virtualenv python-dev

su mangerveggie
cd  # will get you into his home
git clone

Install dependencies

cd Manger-Veggie

# dependancies installation
virtualenv ve

# THIS IS A VERY IMPORTANT LINE: this basically "chroot" your current "python" command to inside the virtualenv
# ALWAYS make sure that you are launching python command with the virtualenv activated
# other you'll have missing dependancies bugs
source ve/bin/activate

pip install -r requirements.txt

pip install gunicorn  # production wsgi server

# you might want to install you favorite database driver there, by default it will be sqlite

Add the production configuration

Create the file /home/mangerveggie/manger-veggie/vegout/ and adapt the following content for it:

SECRET_KEY = 'put something random very long here'

DEBUG = False


# this is where the static assets will be store (for example "jquery.min.js" or css files)
STATIC_ROOT = '/home/mangerveggie/manger-veggie/static_deploy/static/'

Configure the database

python syncdb  # create a superuser when ask

# if you failed to create a super user you can run:
# python createsuperuser
python makemigrations

# yes, again
python syncdb

A first test of the installation

python runserver

or if you want to run the RestoVego version:

python runserver --settings=vegout.vegoresto_settings

If it runs without any error, it's a good sign. You can look at http://localhost:8000 to a play a bit with it if you want (with curl or something like that). You can also run it this way to access if from outside the server on which it is running (or change the port):

python runserver

Never run this setup in production.

Collect the static

Django doesn't serve static files, so it puts them all in one directory that we'll give to nginx.

python collecstatic

Answer "yes".

Setup nginx

If nginx isn't already installed:

apt-get install nginx

Then, put adapt this content and put it into the file /etc/nginx/sites-available/manger-veggie:

server {
    listen 80;
    access_log  /var/log/nginx/manger-veggie_access.log;
    error_log   /var/log/nginx/Manger-Veggie_error.log;

    client_max_body_size 500M;

    location /administration/video/ {
        add_header Access-Control-Allow-Origin *;
        proxy_pass        http://localhost:8000;
        proxy_set_header  X-Real-IP  $remote_addr;

    location / {
        proxy_pass        http://localhost:8000;  # you might want to change the port number if it's already used
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_set_header Host $host;

    location /static/  {
        autoindex    off;
        root /home/mangerveggie/manger-veggie/static_deploy/;

    location /media/  {
        autoindex    off;
        root /home/mangerveggie/manger-veggie/media_prod/;

If you have changed the static/media paths in the you'll have to change it here too.

Symlink this file in the good place:

ln -s /etc/nginx/sites-available/manger-veggie /etc/nginx/sites-enabled/manger-veggie

Reload nginx:

nginx reload

This is not working yet, so if you go to "" you'll have a "bad gateway error" for now.

Test the deployment again

Run this (adapt port if needed):

/home//mangerveggie/ve/bin/gunicorn vegout.wsgi:application -b localhost:8000 --workers=1

Then go to It should be working.

Some common errors:

  • error 400: you haven't configured ALLOWED_HOSTS correctly
  • no css/javascript: either missing collecstatic command or bad path in or nginx config file
  • error 500: huho, that's bad, change DEBUG = False to DEBUG = True in, runlaunch gunicorn, then look at the error (never run with this configuration in production), then once it's finished, switch DEBUG back to False.

Hopefully, by now, everything is fine, stop gunicorn then proceed.

Use supervisord to avoid using a screen

apt-get install supervisor

Then adapt this config file and put it here /etc/supervisor/conf.d/Manger-Veggie.conf:

command=/home/mangerveggie/manger-veggie/ve/bin/gunicorn vegout.wsgi:application -b localhost:8000 --workers=4 

Then run:

supervisorctl update

And now, everything should be running fine, hopefully. If you have an error, look at the previous common error or launch this command to have a bit of informations:

supervisorctl status

Now, remember, every time you modify your python code, you have to do restart the daemon using:

supervisorctl restart manger-veggie

Common supervisorctl commands:

  • start
  • stop
  • restart
  • update # you have to do this every time you modify a /etc/supervisor/conf.d/*.conf file.
  • status

You can replace supervisorctl with an init or systemd script if you want.

You can’t perform that action at this time.