PHP dockerイメージでスーパーバイザを使用すると、権限の問題が発生します。

PHP dockerイメージでスーパーバイザを使用すると、権限の問題が発生します。

私のアプリケーションを構築するために公式のPHPドッカー画像を使用しています。

ケース1:rootユーザーを使用してスーパーバイザを実行し、www-dataユーザーを使用してphp-fpmサブプロセスを実行するとき。常に次のエラーログが表示されます。

FPM initialization failed
failed to open error_log (/proc/self/fd/2): Permission denied (13)

私のスーパーバイザーの設定:

[unix_http_server]
file=/run/supervisord.sock  ; the path to the socket file

[supervisord]
logfile=/var/log/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ; supervisord pidfile; default supervisord.pid

nodaemon=true ; start in foreground if true; default false

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///run/supervisord.sock ; use a unix:// URL for a unix socket

[include]
files = /etc/supervisor.d/*.conf

私のサブプロセスphp-fpmの設定:

[program:php-fpm]
process_name=%(program_name)s
command=php-fpm
user=www-data
autostart=true
autorestart=true
redirect_stderr=false
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

サブプロセスphp-fpmのユーザーをwww-dataからrootに変更すると、完全に実行されます。

ケース2:www-dataユーザーとしてSupervisordを実行し(構成ファイルを一部変更して実行)、www-dataユーザーとしてサブプロセスphp-fpmを実行すると、すべてがうまく機能します。

私のスーパーバイザーの設定:

[unix_http_server]
file=/app/supervisord.sock  ; the path to the socket file

[supervisord]
logfile=/app/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/app/supervisord.pid ; supervisord pidfile; default supervisord.pid
nodaemon=true ; start in foreground if true; default false
user=www-data                     ; setuid to this UNIX account at startup; recommended if root


[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///run/supervisord.sock ; use a unix:// URL for a unix socket

[include]
files = /etc/supervisor.d/*.conf

私のサブプロセスphp-fpmの設定:

[program:php-fpm]
process_name=%(program_name)s
command=php-fpm
user=www-data
autostart=true
autorestart=true
redirect_stderr=false
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

これら2つの状況の違いは何ですか?ありがとうございます!

ベストアンサー1

おすすめ記事