uwsgi+nginx 的简单配置

先在 项目的根目录下 新建一个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

 

相关推荐