First, update the system software package
yum update -y
Second, install the software and dependent management packs
yum -y groupinstall "Development tools" yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel
Three, yum install python36
yum install -y python36 python36-devel
yum install error modification epel.repo
Four, pip3
Pip3 installed by default when installing python36
yum install -y pip3
pip install django==1.11.8
pip install pymysql
pip install requests
Django project to copy / www / directory, the test project is running correctly, run the following command:
python3 ./manage.py runserver 127.0.0.1:8000
Five, pip install uwsgi
pip3 install uwsgi
/ Www / Django project name myDjango create a project file in the root directory myDjango.xml, says:
<uwsgi>
<Socket> 127.0.0.1:8001 </ socket> <-! Internal port, custom ->
<Chdir> / www / myDjango </ chdir> <-! Project Path ->
<module>myDjango.wsgi</module>
<Processes> 4 </ processes> <-! Process number ->
<Daemonize> uwsgi.log </ daemonize> <-! Log Files ->
</uwsgi>
uwsgi -x 'uwsgi.xml'
Error: uwsgi: invalid option - 'x'
Cause: centos, in the absence of libxml2 installed, pip installed uwsgi not support configuration file xml format
solve:
yum install libxml*
pip uninstall uwsgi
pip install uwsgi
Note that deleting ~ / .cache / pip pip installation files cache
Six, nginx configuration
server {
listen 8000;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
#proxy_pass http://tomcatServer;
include uwsgi_params;
uwsgi_pass 127.0.0.1:8001;
#uwsgi_param UWSGI_SCRIPT myDjango.wsgi;
#uwsgi_param UWSGI_CHDIR /root/myDjango;
}
location /static {
alias /www/myDjango/static;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}