Getting Django / NGINX / uWSGI to work on Ubuntu 14.04


I've setup my digitalocean droplet with Ubuntu 14.04. NGINX, uWSGI and a django application which i'm trying to get running.

Could someone please help me out? I think i've had almost every tutorial I could find on these combination of tools. And cant find out what's wrong with my configuration, already tried a crazy amount of things.

This is my project file structure:

-- var
    -- www
        -- myproject
            |-- env/
            |-- conf/
            |   |-- myproject.sock
            |   `-- uwsgi.ini
            `-- public/
                |-- media/
                |-- project.db
                |-- requirements.txt
                |-- static/
                `-- website/
                    |-- dev/
                    |-- gulp/
                    |-- gulpfile.js
                    |-- package.json
                    |-- static/
                    |-- templates/

I installed everything in a virtualenv in the env/ folder of my project.

Just serving the django app by typing python runserver works, I can view it by browsing my webservers IP.

These are my current config files:


server {
    listen 80;

    root /var/www/myproject/public/;
    access_log /var/www/myproject/logs/access.log;
    error_log /var/www/myproject/logs/error.log;

    location /static/ { # STATIC_URL
        alias /var/www/myproject/public/static/; # STATIC_ROOT
        expires 30d;

    location /media/ { # MEDIA_URL
        alias /var/www/myproject/public/media/; # MEDIA_ROOT
        expires 30d;

    location / {
        include         uwsgi_params;
        uwsgi_pass      unix:/var/www/myproject/conf/myproject.sock;


# variables
projectname = myproject
projectdomain =
base = /var/www/myproject

# config
plugins = python
home = ../env
master = true
protocol = uwsgi
env = DJANGO_SETTINGS_MODULE=website.settings
pythonpath = %(base)/public
module = website.wsgi:application
wsgi-file = %(base)/public/website/
socket = %(projectname).sock

I tried running the .ini file by typing uwsgi --ini /var/www/myproject/conf/uwsgi.ini and it does execute, but doesn't seem to set up the server.

When browsing the domain name i see the 'Welcome to nginx!' page so i think it has to do with the uWSGi config.

By : Bas Kaal

I think path to your socket file is incorrect. But anyway, 'Welcome to nginx!' means nginx does not even try to relay anything to uwsgi. If uwsgi was broken, you would see a 502.

I see your config is in sites-available. Did you symlink it to sites-enabled?

By : letitbee

This video can help you solving your question :)
By: admin