flask_demo
flask_demo1
安装 pip install uwsgi
uwsgi配置1
[uwsgi] #源码目录 chdir=/home/ubuntu/data/www/flask_demo #python 虚拟环境 home=/home/ubuntu/data/www/python3_vir module=flask_demo callable=app master=true processes=2 http=0.0.0.0:9527 socket=/home/ubuntu/data/www/logs/demo.sock buffer-size=65535 pidfile=/home/ubuntu/data/www/logs/demo.pid chmod-socket=777 logfile-chmod=644 daemonize=/home/ubuntu/data/www/logs/demo.log
uwsgi配置2
[uwsgi] #源码目录 chdir=/home/ubuntu/data/www/flask_demo1 #python 虚拟环境 home=/home/ubuntu/data/www/python3_vir module=flask_demo1 callable=app master=true processes=2 http=0.0.0.0:8889 socket=/home/ubuntu/data/www/logs/demo1.sock buffer-size=65535 pidfile=/home/ubuntu/data/www/logs/demo1.pid chmod-socket=777 logfile-chmod=644 daemonize=/home/ubuntu/data/www/logs/demo1.log
uwsgi启动两个项目
uwsgi --ini flask_demo.ini
uwsgi --ini flask_demo1.ini
nginx是一个开源的,支持高性能,高并发的代理服务软件 nginx不但是一个优秀的web服务软件,还可以反向代理和负载均衡,以及缓存服务或使用。
nginx配置
http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main ‘$remote_addr - $remote_user [$time_local] "$request" ‘ ‘$status $body_bytes_sent "$http_referer" ‘ ‘"$http_user_agent" "$http_x_forwarded_for"‘; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; #include /etc/nginx/conf.d/*.conf; include /etc/nginx/flask_demo1.conf; include /etc/nginx/demo.d/flask_demo.conf; }
两个配置文件
flask_demo.conf
server { #listen 80 default backlog=2048; listen 443 ssl; server_name xx.cn; #证书文件名称 ssl_certificate demo.d/1_xx.cn_bundle.crt; #私钥文件名称 ssl_certificate_key demo.d/2_xx.cn.key; ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; charset UTF-8; access_log /var/log/nginx/myweb_access.log; error_log /var/log/nginx/myweb_error.log; client_max_body_size 75M; location / { try_files $uri @yourapplication1; } location @yourapplication1 { include uwsgi_params; uwsgi_pass unix:/home/ubuntu/data/www/logs/demo.sock; uwsgi_read_timeout 1800; uwsgi_send_timeout 300; } } server { listen 80; server_name xx.cn; rewrite ^(.*) https://xx.cn$1 permanent; }
flask_demo1.conf
server { listen 80 default backlog=2048; listen 443 ssl; server_name xx.cn; #证书文件名称 ssl_certificate demo1.d/1_xx.cn_bundle.crt; #私钥文件名称 ssl_certificate_key demo1.d/2_xx.cn.key; ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; charset UTF-8; access_log /var/log/nginx/myweb_access1.log; error_log /var/log/nginx/myweb_error1.log; client_max_body_size 75M; location / { try_files $uri @yourapplication; } location @yourapplication { include uwsgi_params; uwsgi_pass unix:/home/ubuntu/data/www/logs/demo1.sock; uwsgi_read_timeout 1800; uwsgi_send_timeout 300; } }
启动nginx
service nginx restart
原文:https://www.cnblogs.com/xiao-apple36/p/12724813.html