Flask构建微信小程序后端③-上云

环境部署

一般会不用root账号部署生产环境,root账号权限最高,被入侵很麻烦

  • 拉代码到www/data目录下
  • 创建python虚拟环境
  • 生产环境配置

启动项目

在这里插入图片描述

export ops_config=production
python manage.py runserver
uwsgi --ini uwsgi.ini
  • uwsgi.ini 配置
[uwsgi]
#源码目录
chdir=/data/www/Order
#python 虚拟环境
home=/data/www/python3_vir
module=manager
callable=app
master=true
processes=4
http=0.0.0.0:8889
socket=/data/www/logs/order.sock
buffer-size=65535
pidfile=/data/www/logs/order.pid
chmod-socket=777
logfile-chmod=644
daemonize=/data/www/logs/order.log
static-map = /static=/data/www/Order/web/static

配置nginx

配置nginx/conf.d 目录下的 order.conf
在这里插入图片描述
在这里插入图片描述

server {
	listen 80 default_server;
	listen 443 default_server;
    server_name  order.54php.cn food.54php.cn;

	ssl on;
    ssl_certificate /data/www/https/chained.pem;
    ssl_certificate_key /data/www/https/domain.key;
    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA;
    ssl_session_cache shared:SSL:50m;


	location /.well-known/acme-challenge/ {
		alias /data/www/challenges/;
		try_files $uri =404;
   	}

	location /static {
		alias  /data/www/Order/web/static/;
	}

	location / {
		try_files $uri @yourapplication;
	}
    location @yourapplication {
      include uwsgi_params;
      uwsgi_pass unix:/data/www/logs/order.sock;
      uwsgi_read_timeout 1800;
      uwsgi_send_timeout 300;
    }
}

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_43746433/article/details/105463862
今日推荐