Method for nginx to output php error log: 1. Edit the php-fpm.conf configuration file and add [error_log = log/error_log]; 2. Edit the php.ini configuration file and add [log_errors = On]; 3. Restart php-fpm.
Problem analysis:
nginx is a web server, so nginx’s access log only records the accessed pages, and there will be no php error log information.
(Recommended tutorial: nginx tutorial)
nginx sends the request for php to the php-fpm fastcgi process for processing. The default php-fpm will only output php -fpm error information, php errorlog cannot be seen in the errors log of php-fpm.
The reason is that the php-fpm configuration file php-fpm.conf defaults to turning off the error output of the worker process and redirecting them directly to /dev/null, so we use nginx’s error log and php- The error log of fpm cannot see the error log of php.
How to solve the problem that php-fpm under nginx does not record php error logs:
1. Modify the configuration in php-fpm.conf and add
catch_workers_output = yes error_log = log/error_log
2 , modify the configuration in php.ini, if not, add
log_errors = On error_log = "/usr/local/lnmp/php/var/log/error_log" error_reporting=E_ALL&~E_NOTICE
3. Restart php-fpm
When PHP execution error occurs, you can see the error log in "/usr/local /lnmp/php/var/log/error_log".
Related recommendations: php training
The above is the detailed content of How to output php error log in nginx. For more information, please follow other related articles on the PHP Chinese website!