php - 主管 + Nginx + PHP-FPM 不重定向标准错误
问题描述
我有一个带有 supervistord、nginx 和 PHP-FPM 的 docker 映像设置。日志记录是使用 awslogs 驱动程序完成的。一些 PHP 致命错误会像写入文件时被拒绝的权限一样进入 awslogs。来自 supervisord、nginx 和 PHP-FPM 的所有错误日志都发送到 /dev/stderr,但它们不会出现在 awslogs 中。如果我将 PHP-FPM 配置中的 error_log 配置到文件中,则会写入致命错误。
应该怎么做才能将标准错误从 PHP-FPM “转发”到 Nginx 或 Supervisord?
监督配置:
[unix_http_server]
file=/dev/shm/supervisor.sock ; (the path to the socket file)
[supervisord]
logfile=/tmp/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
loglevel=info ; (log level;default info; others: debug,warn,trace)
pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false ; (start in foreground if true;default false)
minfds=1024 ; (min. avail startup file descriptors;default 1024)
minprocs=200 ; (min. avail process descriptors;default 200)
user=root ;
; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///dev/shm/supervisor.sock ; use a unix:// URL for a unix socket
[program:php-fpm]
command = /usr/local/sbin/php-fpm --nodaemonize --fpm-config /usr/local/etc/php-fpm.d/www.conf
autostart=true
priority=5
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
;stderr_logfile=/dev/stderr
redirect_stderr=true
stderr_logfile_maxbytes=0
[program:nginx]
command=/usr/sbin/nginx -g "daemon off;"
autostart=true
priority=10
stdout_events_enabled=true
stderr_events_enabled=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
;stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
redirect_stderr=true
stopsignal=QUIT
[include]
files = /etc/supervisor/conf.d/*.conf
Nginx 配置:
server {
listen 80; ## listen for ipv4; this line is default and implied
listen [::]:80 default ipv6only=on; ## listen for ipv6
root /var/www/html/public;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name _;
# Disable sendfile as per https://docs.vagrantup.com/v2/synced-folders/virtualbox.html
sendfile off;
# Add stdout logging
error_log /dev/stderr;
access_log /dev/stdout;
....
}
我一直在努力,因为很多小时和谷歌搜索,但什么都没有......
解决方案
推荐阅读
- failover - PROXY for MySQL HA 和负载平衡和故障转移解决方案
- java - 打开 hiveserver2 时,Hive 日志卡在 Web ui 上
- python - 如何解决 - ModuleNotFoundError: No module named 'gekko', in spyder?
- docker - Yocto 图像构建失败
- python - 由于在 ImageDataGenerator 中调整图像大小,是否会丢失任何特征?
- c++ - 使用信号侦听器线程 - 我该如何停止它?
- java - 尝试将 JAR 转换为 EXE
- scala - 如何迭代包含特定值的枚举值?
- python-xarray - 在 xarray 中索引超过 4 个维度
- c++ - 虚函数调用顺序