Nginx,Uwsgi and Django App Not Found

centosdjangonginxpythonuwsgi

I have configured Nginx with uWSGI and Django on CentOS.

Django Directory(contains all my django app): /home

Django Project Directory: /home/hdblog

/home/hdapp.py contains below:

import os, sys
sys.path.append('/home')
os.environ['DJANGO_SETTINGS_MODULE'] = 'hdblog.settings'

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()

And i'm using below command:

/etc/init.d/uwsgi --socket 127.0.0.1:8889 --master --workers 2 --harakiri 30 --disable-logging --daemonize /tmp/daemonize.log --pidfile /tmp/pidfile.txt --vacuum --gid 500 --uid 500 --pythonpath /home/hdblog --module hdapp

Plus,my /etc/nginx/conf.d/default.conf contains to below line:

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

As you can see everything is ok,but i'm seeing on 80 port

uWSGI Error

Python application not found

How to solve this problem? Thanks.

Best Answer

If the module hdapp map to the file /home/hdapp.py, you have to add /home to the pythonpath