uWSGI 权限问题

Nal*_*lum 6 python nginx chef uwsgi

我正在尝试设置一个厨师食谱,以使我的网站运行,并且一切似乎都运行良好,但uWSGI出现以下错误:

*** has_emperor mode detected (fd: 6) ***
[uWSGI] getting INI configuration from app-cms.ini
removed uwsgi instance app-cms.ini
Run Code Online (Sandbox Code Playgroud)

不再说这个:

open("/var/www/app-cms/logs/uwsgi.log"): Permission denied [utils.c line 246]
Run Code Online (Sandbox Code Playgroud)

现在正在创建该日志文件,其中包含以下内容:

*** Starting uWSGI 1.0.3-debian (64bit) on [Thu Feb  6 12:00:43 2014] ***
compiled with version: 4.6.3 on 17 July 2012 02:26:54
current working directory: /etc/uwsgi/apps-enabled
writing pidfile to /var/www/ediflo-cms/run/ediflo-cms.pid
detected binary path: /usr/bin/uwsgi-core
setgid() to 33
setuid() to 33
chdir(): Permission denied [uwsgi.c line 1723]
chdir(): Permission denied [uwsgi.c line 975]
Run Code Online (Sandbox Code Playgroud)

我不确定它试图去哪里chdir()

我开始uWSGI在皇帝模式,有它看/etc/uwsgi/apps-enabled/ini使用下面的新贵配置文件的文件:

description "uWSGI"
start on runlevel [2345]
stop on runlevel [06]

respawn

exec uwsgi --emperor /etc/uwsgi/apps-enabled --uid uwsgi --gid www-data --logto /var/log/uwsgi/uwsgi.log
Run Code Online (Sandbox Code Playgroud)

这是我的uWSGI应用程序配置:

[uwsgi]
; define variables to use in this script
; process name for easy identification in top
project = app-cms
base_dir = /var/www/app-cms
chdir = %(base_dir)

pythonpath = %(base_dir)/env/bin

uid = www-data
gid = www-data

procname = %(project)

; This value needs to be tuned
workers = 4

; Create pid file for easier process management
pidfile = %(base_dir)/run/%(project).pid

; Specify your app here
module = %(project)-wsgi:application

log-reopen = true
logto = %(base_dir)/logs/uwsgi.log

chmod-socket = 660

vacuum = True
enable-threads = True

; unix socket
socket = /tmp/app-cms-server.sock
; Enable stats
stats = /tmp/app-cms-stats.sock
Run Code Online (Sandbox Code Playgroud)

小智 3

如果Emperor作为非特权用户运行,vassals不能下降到特定的uid和gid,并且更重要的master-as-root没有意义(使用它通常是一个坏主意,它仅适用于需要访问硬件以获取特定功能)。

检查 /var/www/app-cms/logs/uwsgi.log 是否已存在并且由 root 拥有,很可能它是先前尝试的结果,现在非特权进程无法以写入模式访问它。

最后,不要将皇帝和附庸映射到同一个日志文件,它是隐式的,因为文件描述符 2 是继承的,如果附庸与皇帝具有不同的权限,则可能会导致各种问题(这不是你的情况)