Step one: Build a python environment
It is best to use pyenv to manage the Python environment in multiple versions very well.
Step two: Build a Django environment
Install by using PIP install django==1.12.1
When installed, you can use the Create a lab project to make Django successful.
django.admin.py Startproject Demo
Then CD demo inside
Use Python manag.py Runserver to experiment with whether Django can start
Step Three: Build UWGSI environment
Install using the PIP install Uwsgi
Edit a Uwsgi.ini file
Content according to their own needs to set
[Uwsgi]
Socket = 0.0.0.0:9000
Master = True
Pidfile =/usr/local/nginx/uwsgi.pid
processes = 8
Workers = 2
ChDir =/data/www/demo
Pythonpath =/data/www
Profiler=true
Memory-report=true
Enable-threads = True
Logdate=true
limit-as=6048
Daemonize=/data/logs/django.log
Fourth step: Build Nginx Environment
server {
Listen 81;
server_name demo.domain.com;
Location/{
Uwsgi_pass 127.0.0.1:9001;
Include Uwsgi_params;
Uwsgi_param Uwsgi_chdir/data/www/omserverweb/demo;
Uwsgi_param Uwsgi_script Wsgi;
Access_log/var/log/nginx/testaccess.log main;
}
}
Where problems can be seen in Nginx and Uwsgi logs to resolve the step-by-step exclusion
First troubleshoot Django in troubleshooting Uwsgi
PYTHON+DJANGO+UWSGI Building Environment