Home >Backend Development >PHP Problem >How to output PHP error log with php-fpm

How to output PHP error log with php-fpm

王林
王林Original
2021-06-25 14:15:433542browse

How php-fpm outputs PHP error logs: First edit the php-fpm.conf configuration file and add the configuration [error_log = log/error_log]; then edit the php.ini configuration file to enable the error log; finally restart php-fpm will do.

How to output PHP error log with php-fpm

The operating environment of this article: windows10 system, php 7.3, thinkpad t480 computer.

Foreword:

We know that nginx is a web server, so the access log of nginx only records the accessed pages, and there will be no error log information of php.

nginx sends the request for php to the php-fpm fastcgi process for processing. The default php-fpm will only output the error message of php-fpm, and php cannot be seen in the errors log of php-fpm. errorlog. 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 can neither see the error log of nginx nor the error log of php-fpm. to the php error log.

How to solve the problem that php-fpm under nginx does not record php error logs:

Modify the configuration in php-fpm.conf and add it if there is no configuration.

catch_workers_output = yes
error_log = log/error_log

Modify php. ini configuration, if not, add

log_errors = On
error_log = "/usr/local/lnmp/php/var/log/error_log"
error_reporting=E_ALL&~E_NOTICE

Restart php-fpm

When PHP executes an error, you can see the error log in "/usr/local/lnmp/php/var /log/error_log" is in.

Related video sharing: php video tutorial

The above is the detailed content of How to output PHP error log with php-fpm. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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