Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

display_errors for php5-fpm not working with nginx

Tags:

php

nginx

I am running nginx with php5-fpm and want to enable the display_errors. I am running a virtual host, so please help in making a way to enable display_errors , display_startup_errors.

I tried modifying /etc/php5/fpm/php.ini.

;display_errors Default Value: On Development Value: On ;Production Value: Off  ;display_startup_errors Default Value: On Development Value: On ;Production Value: Off ;error_reporting Default Value: E_ALL Development Value: E_ALL ;Production Value: E_ALL & ~E_DEPRECATED ;html_errors Default Value: On Development Value: On ;Production value: Off ;log_errors Default Value: On Development Value: On ;Production Value: On 

Is it require to have multiple ini files for each different virtual host, does vhost makes any difference for php configuration ?

I am also trying set_ini() , but it is not showing any effect. And I restarted nginx and php5-fpm after making changes in php.ini file.

like image 467
Pranav Avatar asked Dec 18 '12 08:12

Pranav


People also ask

How does PHP-FPM work with NGINX?

Install PHP-FPM PHP-FPM, on the other hand, runs outside the NGINX environment by creating its own process. Therefore when a user requests a PHP page the nginx server will pass the request to PHP-FPM service using FastCGI. The installation of php-fpm in Ubuntu 18.04 depends on PHP and its version.

What is the default port for PHP-FPM?

By default, this configuration starts a PHP-FPM server listening on port 9000 that binds to 127.0. 0.1 (localhost). If your intention is to run PHP-FPM on a separate server, then you will need to amend the following values in your PHP-FPM domain configuration file.

How does NGINX communicate with PHP?

NGINX web server (as reverse proxy) serves PHP applications through the FastCGI protocol (as a backend application server). NGINX employs PHP-FPM (FastCGI Process Manager), an alternative PHP FastCGI implementation that runs in the background as a daemon, listening for CGI requests.


1 Answers

The php.ini does nothing for php-fpm.

If you are using php-fpm: You must provide the configuration change in the fpm pool config associated with your web application. Where these are located depends on your system. The probably locations are:

  • /etc/php-fpm.d/mydomain.conf (if things have been set up neatly)
  • /etc/php-fpm.conf (if you are only using one conf for php-fpm)

Your config paths are different from mine, so poke around to see what you have in there. Don't make changes in /etc/php-fpm.conf if a suitable conf exists in /etc/php-fpm.d/.

If you are not using php-fpm: Update php.ini with the correct configuration.

Correct your configuration: In the configuration shown in the question, you have uncommented documentation rather than provided the correct settings. You had better undo those changes, because PHP won't understand them.

The correct lines for php-fpm are:

    ; enable display of errors     php_flag[display_errors] = on     php_flag[display_startup_errors] = on 

The correct lines for normal php are:

    ; enable display of errors     display_errors = On     display_startup_errors = On 

Advice: Do not use these options in a production environment. Best wishes.

like image 189
Kevin A. Naudé Avatar answered Sep 28 '22 10:09

Kevin A. Naudé