| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [View Raw Code] [Original HTTPS Page] |
uWSGI
安装配置 uWSGI : pip3 install uwsgi
创建软链接 : ln /usr/local/python3/bin/uwsgi /usr/bin/uwsgi
进入项目主目录 测试 uWSGI : uwwsgi --http 192.168.33.131:8000 --file Qshop/wsgi.py --static-map=/static=static
配置文件形式 使用 uWSGI
创建 uwsgi.ini 配置文件
编写配置文件 uwshi.ini (部署项目时要删除注释的空格)
[uwsgi]
chdir=/opt/Qshop ## 项目目录
module=Qshop.wsgi:application ## 项目指定的 application
socket=/opt/script/uwsgi.sock ## 指定 sock 文件路径
workers=5 ## 进程个数
pidfile=/opt/script/uwsgi.pid
http=192.168.33.131:8000 ## 指定 ip 端口
static-map=/static=/opt/Qshop/static # 指定静态文件
uid=root ## 用户
gid=root ## 组
master=true ## 启用主线程
vacuum=true ## 自动移除 unix Socket 和 pid 文件,当服务网停止时
enable-threads=true ## 启用线程
thunder-lock=true ## 序列化接受的内容,如果可能的话
harakiri=30 ## 设置自中断时间
post-buffreing=4096
daeminize=/opt/script/uwsgi.log ## 设置日志目录启动 uWSGI
停止 uWSGI
Nginx
Nginx 配置
备份配置文件 : cp /usr/local/nginx/conf/nginx.conf /usr/local/ngiinx/conf/nginx.conf.bak
修改配置文件 nginx.conf (部署项目时要删除注释的空格)
http {
# 文件拓展名与文件类型映射表
include mime.types;
# 默认文件类型, 默认为 text/plain
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_forwawrded_for"';
# 访问记录日志
access_log logs/access.log main;
# 允许 sendfile 方式传输文件
sendfile on;
# tcp_nopush on;
# keepalive_timeout 0;
# 连接超时时间
keepalive_timeout 65;
# 允许 gzip 压缩
gzip on;
# 设置支持压缩的 content-type
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
server {
# 端口号
listen 80;
server_name Qshop;
charset utf-8;
location / {
include uwsgi_params;
uwsgi_connect_timeout 30;
uwsgi_pass unix:/opt/script/uwsgi.sock;
}
error_page 500 502 503 504 /50.html;
location = /static/ {
alias /opt/Qshop/static;
index index.html index.html,
}
}
}
启动项目
修改 uwwsgi.ini (修改 http=127.0.0.1:8000 不允许外网通过 ip + :8000 端口直接访问) (部署项目时要删除注释的空格)
[uwsgi]
chdir=/opt/Qshop ## 项目目录
module=Qshop.wsgi:application ## 项目指定的 application
socket=/opt/script/uwsgi.sock ## 指定 sock 文件路径
workers=5 ## 进程个数
pidfile=/opt/script/uwsgi.pid
http=1127.0.0.1:8000 ## 指定 ip 端口
static-map=/static=/opt/Qshop/static # 指定静态文件
uid=root ## 用户
gid=root ## 组
master=true ## 启用主线程
vacuum=true ## 自动移除 unix Socket 和 pid 文件,当服务网停止时
enable-threads=true ## 启用线程
thunder-lock=true ## 序列化接受的内容,如果可能的话
harakiri=30 ## 设置自中断时间
post-buffreing=4096
daeminize=/opt/script/uwsgi.log ## 设置日志目录| Back | FazBrowse Home | New Git URL |