如何配置 Nginx 将发送到 php-fpm 的请求记录到日志中?目标是将脚本路径信息或 Nginx 位置等应用到日志中。
答案1
您的站点配置中有一个 php 部分。您只需在该部分中添加 access_log 指令即可
location ~ .php$ {
fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
include fastcgi_params;
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
# fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_pass unix:/run/php/php5.6-fpm.sock;
access_log /var/log/nginx/phpfpmonly-access.log;
}