Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP-FPM doesn't write to error log

Tags:

php

I've just installed a nginx+php-fpm server. Everything seems fine except that PHP-FPM never writes error to its log.

fpm.conf

[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;   } } 

I've made an erroneous php script and run, and see error output on the web browser. Also nginx error log states stderr output from fpm with the same message. I've check that the user have write (I've even tried 777) permission to the appointed log folder. Even the appointed error.log file has be created successfully by php-fpm. However, the log file is always empty, no matter what outrageous error has been made from php script.

What's going on?

[Found the reason quite a while later]

It was permission. Changed the owner to the sites's users solved the problem.

like image 972
eidng8 Avatar asked Dec 30 '11 08:12

eidng8


People also ask

Where does PHP-FPM log errors?

A complete debug log for PHP-FPM errors can be found in the /opt/bitnami/php/var/log directory.

How do I enable PHP error logging?

Enable Error Logging in php. If you want to enable PHP error logging in individual files, add this code at the top of the PHP file. ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); Now, you must enable only one statement to parse the log errors in the php.

How can I tell if PHP-FPM is running?

First open the php-fpm configuration file and enable the status page as shown. Inside this file, find and uncomment the variable pm. status_path = /status as shown in the screenshot. Save the changes and exit the file.


1 Answers

This worked for me:

; 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 

Edit:

The file to edit is the file that configure your desired pool. By default its: /etc/php-fpm.d/www.conf

like image 165
michaelbn Avatar answered Nov 15 '22 23:11

michaelbn