uwsgi and nginx deploy Django Service

First start with the service test mode

1. configured database

2. setting configuration file: address database, address static files, debug is set to True

3. Database Migration

4. Start Services: python manage.py runserver 0.0.0.0:8000

Start with uwsgi way

1. Install uwsgi, reference links: https://www.runoob.com/python3/python-uwsgi.html

Solve three problems:

yum install python-devel

yum remove pcre-devel

When executed uwsgi start the service, use the python2 interpreter, the interpreter will use python3 re-installed, to resolve reference documentation: https://www.cnblogs.com/zoujl/p/11011041.html

2. Establish a soft link: ln -s /home/yiqian/uwsgi/uwsgi-2.0.18/uwsgi / usr / bin / uwsgi

3. Start with the command: uwsgi --http: 8000 --module requestnew.wsgi --py-autoreload = 1

4. The configuration file uwsgi.ini root Run uwsgi --ini uwsgi.ini

[uwsgi]
chdir=/home/yiqian/pj/requestnew
module = requestnew.wsgi
processes = 5
threads=4
enable-threads=true
lazy-apps=true
http = 0.0.0.0:8000
#socket  = 0.0.0.0:8000
vacuum = true

nginx and uwsgi way to start

1. Install nginx, reference links: https://blog.csdn.net/t8116189520/article/details/81909574

2.setting debug file set to False, the new added STATIC_ROOT = '/ home / yiqian / pj / requestnew / tmp /'

3. Do python3 manage.py collectstatic, in the root directory of the static files are hit under the tmp

4.uwsgi start, with the change socket startup mode, execute nohup uwsgi --ini uwsgi.ini ../log/uwsgi.log &

[uwsgi]
chdir=/home/yiqian/pj/requestnew
module = requestnew.wsgi
processes = 5
threads=4
enable-threads=true
lazy-apps=true
#http = 0.0.0.0:8000
socket  = 0.0.0.0:8000
vacuum = true

The configuration file nginx.conf

the root User; 
worker_processes. 1; 

the error_log /var/log/nginx/error.log The warn; 
PID /var/run/nginx.pid; 


Events { 
    worker_connections 1024; 
} 


HTTP { 
    # file extension file type mapping table 
    include mime.types ; 
    # default file type 
    default_type file application / OCTET-Stream; 
    upstream requestnew { 
        Server 127.0.0.1:8000; 
	} 

    Server { 
       the listen 8090; 
       server_name localhost; 
       # nginx the inlet request directly to the reverse proxy to uwsgi 
       LOCATION / { 
         uwsgi_pass requestnew; 
         the include / etc / nginx / uwsgi_params; 
		} 
    # nbcrm process by static files nginx 
		LOCATION / static {
			alias /home/yiqian/pj/requestnew/tmp;
        }
    }
}

6.nginx -t detection nginx file

7.nginx -c /usr/local/nginx/conf/nginx.conf, specify the startup configuration file

8.nginx -s reload start nginx

Overall reference documentation: https://www.cnblogs.com/zouzou-busy/p/11625994.html

 

 

 

 

Guess you like

Origin www.cnblogs.com/letmeiscool/p/11867217.html