1
votes

I am following this tutorial but i am having a problem I'm getting a 502 Nginx error.

tutorial link

Ive check the error logs and it says

uwsgi.log

ImportError: No module named khcards.wsgi

my uwsgi file looks like this

[uwsgi]
# variables
projectdomain = khcardsonline.co.uk www.khcardsonline.co.uk

uid = www-data
god = www-data
chmod = 775
# config
plugins = python
master = true
pidfile=/tmp/project-master.pid
chdir = /var/www/example.com/src/khcards
protocol = uwsgi
env = DJANGO_SETTINGS_MODULE=khcards.settings
home = /var/www/example.com/env
pythonpath = /var/www/example.com/src/khcards
module = khcards.wsgi:application
socket = 127.0.0.1:8889
logto = /var/www/example.com/logs/uwsgi.log
#below line runs it as a daemon in background
daemonize = /var/log/uwsgi/khcards.log

my nginx.conf

server { listen 80; server_name domain www.domain.co.uk; root /var/www/example.com/src/khcards; access_log /var/www/example.com/logs/access.log; error_log /var/www/example.com/logs/error.log;

location /static/ { # STATIC_URL
    alias /var/www/example.com/src/static/static/; # STATIC_ROOT
    expires 30d;
}

location /media/ { # MEDIA_URL
    alias /var/www/example.com/src/media/; # MEDIA_ROOT
    expires 30d;
}

location / {
    include uwsgi_params;
    uwsgi_pass 127.0.0.1:8889;
}

}

When i run

sudo service uwsgi restart

the terminal spits out

  • Restarting app server(s) uwsgi [ OK ]

but when i do

sudo service nginx restart

the terminal spits out

Restarting nginx: nginx.

Does this mean Nginx isn't configured correctly?

1

1 Answers

1
votes

Try changing

chdir = /var/www/example.com/src/khcards

to

chdir = /var/www/example.com/src