Home > Operation and Maintenance > Nginx > How to output php error log in nginx

How to output php error log in nginx

王林
Release: 2020-11-03 09:27:36
Original
2806 people have browsed it

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.

How to output php error log in nginx

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
Copy after login

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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template