Home >Operation and Maintenance >Nginx >How to enable php error reporting function in Nginx
Modify the php.ini configuration file
php --iniThis command will find the location of the php.ini configuration file. After getting the location of the php.ini configuration file, we can find the following two configuration items:
display_errors = Off error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICTThe above configuration items determine whether PHP displays error messages and error level settings. We need to set display_errors to On to enable the display of PHP error messages on the page. At the same time, error_reporting determines which error information needs to be displayed on the page. Modify the above two configuration items as follows:
display_errors = On error_reporting = E_ALL
Modify the Nginx configuration file
location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_script_name; fastcgi_param PHP_VALUE "display_errors=On"; fastcgi_param PHP_ADMIN_VALUE "error_reporting=E_ALL"; include fastcgi_params; }The above code connects the FastCGI module with PHP and sets two parameters for PHP: display_errors and error_reporting, making it a global setting . It should be noted that the above code only modifies the Nginx configuration file and does not reload Nginx.
Reload Nginx
sudo service nginx reload
The above is the detailed content of How to enable php error reporting function in Nginx. For more information, please follow other related articles on the PHP Chinese website!