程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python wechat applet server django+ngnix+uwsgi

編輯:Python

List of articles

  • Preface
  • One 、uwsgi
  • Two 、Nginx
  • summary


Preface

Environmental Science :ubuntu18,python3
Use python Write wechat applet backend , Applet domain name needs https And filing , So using django+ngnix+uwsgi Set up the environment .


One 、uwsgi

pip3 install uwsgi

[uwsgi]
#socket be responsible for nginx and uwsgi signal communication 
socket = /home/ubuntu/wx_test/uwsgi.sock
# Specify project path 
chdir = /home/ubuntu/wx_test
#django project wsgi
wsgi-file = /home/ubuntu/wx_test/wx_test/wsgi.py
#pid Port file 
pidfile = /home/ubuntu/wx_test/uwsgi.pid
# Background operation , Print log output 
daemonize = /home/ubuntu/wx_test/uwsgi.log
# The main process 
master = true
# sign out 、 Clean up files on restart 
vacuum = true
# Configuration process 
processes = 6
# Configure threads 
threads = 100
# Serialize accepted content 
thunder-lock = true
# Enable the thread 
enable-thread = true
# Set the interrupt time 
harakiri = 30
# Set the buffer 
post-buffering = 4096
#python Change automatic restart uwsgi
py-autoreload = 1

uwsgi --ini wx_test.ini

Two 、Nginx

sudo apt-get install nginx
cd /etc/nginx
modify nginx user vi nginx.conf Change the first line to user root;
cd conf.d
sudo touch wx_test.conf
sudo vi wx_test.conf

server {

#SSL Access port number is 443
listen 443 ssl;
# Fill in the domain name of the binding certificate 
server_name xmueye.com;
# Certificate file name 
ssl_certificate /etc/nginx/conf.d/1_xmueye.com_bundle.crt;
# Private key file name 
ssl_certificate_key /etc/nginx/conf.d/2_xmueye.com.key;
ssl_session_timeout 5m;
# Please configure according to the following protocol 
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
# Please configure according to the following package , Configure encryption suite , The writing follows openssl standard .
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
charset UTF-8;
client_max_body_size 75M;
# Specify project path uwsgi
location / {

#nginx and uwsgi Communication protocol of 
include /etc/nginx/uwsgi_params;
#nginx Corresponding uwsgi socket
uwsgi_pass unix:/home/ubuntu/wx_test/uwsgi.sock;
}
# Specify static file directory 
location /static/ {

alias /home/ubuntu/wx_test/static_all;
index index.html index.htm;
}
}

restart nginx The server
sudo service nginx restart

summary

Refer to the following article
https://blog.csdn.net/qq_43467898/article/details/83187698
https://cloud.tencent.com/document/product/400/35244
https://www.runoob.com/django/django-nginx-uwsgi.html
https://www.jb51.net/article/160820.htm


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved