PHP-FPM がエラーログに書き込みません 質問する

PHP-FPM がエラーログに書き込みません 質問する

nginx+php-fpm サーバーをインストールしました。PHP-FPM がログにエラーを書き込まないことを除いて、すべて正常に見えます。

設定ファイル

[default]
listen = /var/run/php-fpm/default.sock
listen.allowed_clients = 127.0.0.1
listen.owner = webusr
listen.group = webusr
listen.mode = 0666
user = webusr
group = webusr
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.status_path = /php/fpm/status
ping.path = /php/fpm/ping
request_terminate_timeout = 30s
request_slowlog_timeout = 10s
slowlog = /var/log/php-fpm/default/slow.log
chroot = /var/www/sites/webusr
catch_workers_output = yes
env[HOSTNAME] = mapsvr.mapking.com
php_flag[display_errors] = on
php_admin_value[error_log] = /var/log/php-fpm/default/error.log
php_admin_flag[log_errors] = on

nginx.conf

server
{
  listen        80 default_server;
  server_name   _;

  charset       utf-8;
  access_log    /var/log/nginx/access.log rest;

  include       conf.d/drops.conf.inc;

  location      /
  {
    root        /var/www/sites/webusr/htdocs;
    index       index.html index.htm index.php;
  }

  # pass the PHP scripts to FastCGI server listening on socket
  #
  location      ~ \.php$
  {
    root           /var/www/sites/webusr/htdocs;
    include        /etc/nginx/fastcgi_params;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME /htdocs/$fastcgi_script_name;
    if (-f $request_filename)
    {
      fastcgi_pass   unix:/var/run/php-fpm/default.sock;
    }
  }

  location      = /php/fpm/status
  {
    include        /etc/nginx/fastcgi_params;
    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_pass   unix:/var/run/php-fpm/default.sock;
  }

  location      = /php/fpm/ping
  {
    include        /etc/nginx/fastcgi_params;
    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_pass   unix:/var/run/php-fpm/default.sock;
  }

  # redirect server error pages to the static page /50x.html
  #
  error_page    500 502 503 504  /50x.html;
  location      = /50x.html
  {
    root        /usr/share/nginx/html;
  }
}

エラーのある PHP スクリプトを作成して実行すると、Web ブラウザーにエラー出力が表示されます。また、nginx エラー ログには、同じメッセージで fpm からの stderr 出力が示されています。指定されたログ フォルダーへの書き込み権限 (777 も試しました) がユーザーに付与されていることを確認しました。指定された error.log ファイルも、php-fpm によって正常に作成されています。ただし、PHP スクリプトからどのようなとんでもないエラーが発生しても、ログ ファイルは常に空です。

どうしたの?

[しばらくして理由が分かりました]

それは許可の問題でした。所有者をサイトのユーザーに変更すると問題は解決しました。

ベストアンサー1

これは私にとってはうまくいきました:

; Redirect worker stdout and stderr into main error log. If not set, stdout and
; stderr will be redirected to /dev/null according to FastCGI specs.
; Default Value: no
catch_workers_output = yes

編集:

編集するファイルは、希望するプールを構成するファイルです。デフォルトでは、/etc/php-fpm.d/www.conf です。

おすすめ記事