Getting Django / NGINX / uWSGI to work on Ubuntu 14.04

Question!

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/
                |-- manage.py
                |-- media/
                |-- project.db
                |-- requirements.txt
                |-- static/
                `-- website/
                    |-- dev/
                    |-- gulp/
                    |-- gulpfile.js
                    |-- package.json
                    |-- settings.py
                    |-- static/
                    |-- templates/
                    |-- urls.py
                    `-- wsgi.py

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

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

These are my current config files:

/etc/nginx/sites-available/myproject

server {
    listen 80;
    server_name myproject.nl www.myproject.nl;

    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;
    }
}

/var/www/project/conf/uwsgi.conf

[uwsgi]
# variables
projectname = myproject
projectdomain = myproject.nl
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/wsgi.py
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


Answers
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