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 .
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
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
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