本文主要是介绍uwsgi nginx 的一些参数,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
在项目目录下创建uwsgiconfig.ini文件
[uwsgi]
home=/home/ # 指定python虚拟环境,意义:使用指定的python,路径写到bin目录上一层
chdir=/home/test/project # 项目目录,意义: 将路径切换到项目目录下
wsgi-file=manager.py # 项目路径下,指定加载的启动文件
module=manager 或 manager:app # 项目路径下,指定加载的模块,同wsgi-file(若“:app”写在module中,则callable不需要再写)
callable=app # 指定uWSGI加载的启动文件(模块)中哪个变量将被调用
master=true # 启动主线程
processes=4 # 设置工作进程的数量
threads=2 # 设置每个工作进程的线程数
socket=127.0.0.1:8888 # 指定socket地址 配合nginx使用
vacuum=true # 当服务器退出时自动删除unix socket文件和pid文件
logfile-chmod=644 # 指定日志文件的权限
daemonize=%(chdir)/cloudmonitor.log # 进程在后台运行,并将日志打印到指定文件
pidfile=%(chdir)/cloudmonitor.pid # 在失去权限前,将主进程pid写到指定的文件
uid=git # uWSGI服务器运行时的用户id
gid=git # uWSGI服务器运行时的用户组id
procname-prefix-spaced=cloudmonitor # 指定工作进程名称的前缀
uwsgi uwsgiconfig.ini
uwsgi --ini uwsgiconfig.ini 启动uwsgi服务
uwsgi uwsgiconfig.ini --daemonize //后台运行启动
uwsgi --stop uwsgi.pid //停止服务
uwsgi --reload uwsgi.pid //可以无缝重启服务
nginx
在/etc/nginx/nginx.conf文件中 http 下添加 include /etc/nginx/conf.d/test.conf 其中‘test’为自己取的应用配置名
在/etc/nginx/conf.d/下,创建名为 test.conf 文件,写入一下内容:
server {# 监听端口listen 80;# 监听ip 换成服务器公网IPserver_name localhost;charset utf-8;client_max_body_size 75M;#动态请求location / {include uwsgi_params;# 与uwsgi socket对应uwsgi_pass 127.0.0.1:8888;}
}
-
nginx //启动
-
nginx -s stop/quit //停止
-
nginx -s reload //重启加载配置
这篇关于uwsgi nginx 的一些参数的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!