码迷,mamicode.com
首页 > 其他好文 > 详细

uwsgi+nginx 的简单配置

时间:2020-03-08 19:17:59      阅读:59      评论:0      收藏:0      [点我收藏+]

标签:line   pes   简单   pidfile   stream   serve   numbers   shu   connect   

先在 项目的根目录下 新建一个uwsgi.ini的文件(名字可以改)

uwsgi 配置

[uwsgi]
socket=外网ip:端口(使用nginx连接时,使用socket)
http=外网ip:端口(直接做web服务器,使用http)
chdir=项目根目录
wsgi-file=项目中wsgi.py文件的目录,相对于项目根目录
processes=4
threads=2
master=True
pidfile=uwsgi.pid
daemonize=uswgi.log

简单配置具体文件:

[uwsgi]
socket=172.31.215.139:8000  #使用的是阿里云 此处为本地ip地址及端口号
chdir=/root/wwwroot/viruses_app/
wsgi-file=analysis_platform/wsgi.py
processes=1
threads=2
#buffer-size = 65536
master=True
pidfile=uwsgi.pid
daemonize=uwsgi.log

 

wsgi的启动及停止

启动:uwsgi --ini uwsgi.ini
停止:uwsgi --stop uwsgi.pid
重启:uwsgi --reload uwsgi.pid

nginx简单配置文件(同服务器多项目,简单配置)

user root;  #确保静态文件可以正常访问
events{

worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;
server {
listen 80;
server_name 47.105.41.151
charset utf-8;

location / {
include uwsgi_params;
uwsgi_pass 172.31.215.139:8000;
#uwsgi_param UWSGI_SCRIPT analysis_platform.wsgi;
#uwsgi_param UWSGI_CHDIR /root/wwwroot/viruses_app/analysis_platform/; #项目路径
}
location /static/ {
alias /root/wwwroot/viruses_app/static/; #静态资源路径
}
}
server {
listen 8080;
server_name 47.105.41.151
charset utf-8;

location / {
include uwsgi_params;
uwsgi_pass 172.31.215.139:8001;
#uwsgi_param UWSGI_SCRIPT analysis_platform.wsgi;
#uwsgi_param UWSGI_CHDIR /root/wwwroot/viruses_app/analysis_platform/; #项目路径
}
location /static/ {
alias /root/wwwroot/officepage/static/; #静态资源路径
}
}
}

 

引用查考:https://www.jianshu.com/p/0e9890d3d309

uwsgi+nginx 的简单配置

标签:line   pes   简单   pidfile   stream   serve   numbers   shu   connect   

原文地址:https://www.cnblogs.com/sly27/p/12443981.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!