Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP FPM returns HTTP 500 for all PHP errors

Tags:

I am running nginx with PHP-FPM. My nginx configuration for handling php files looks like this:

location  ~ \.php$ {             set $php_root /home/me/www;             fastcgi_pass   127.0.0.1:9000;             fastcgi_index  index.php;             fastcgi_param  SCRIPT_FILENAME  $php_root$fastcgi_script_name;             include /etc/nginx/fastcgi_params;         } 

Now, I have a simple php file like this:

<?php      ech "asd"      asd"" ?> 

Yes, with an obvious error. When I try accessing the php file, instead of tracing a syntax error, I always get a HTTP 500 Internal Server Error.I tried using error_reporting(-1); but still it always returns HTTP 500. How do I get PHP to print the exact error instead of returning a generic HTTP 500?

like image 202
ErJab Avatar asked Feb 09 '10 05:02

ErJab


People also ask

Does PHP-FPM use PHP INI?

FPM uses php. ini syntax for its configuration file - php-fpm. conf , and pool configuration files.

How can I see PHP-FPM logs?

A complete debug log for PHP-FPM errors can be found in the /opt/bitnami/php/var/log directory.

Does NGINX require PHP-FPM?

PHP-FPM is installed and active for NGINX. And that's it, you've got NGINX up and running with PHP-FPM support. Remember, when you build your virtualhost configuration files, you'll need to make sure to include PHP support in those. For that, you can use the /etc/nginx/sites-available/default file as an example.


2 Answers

Try to find the following line in your php.ini:

 display_errors = Off 

then make it on

like image 148
Young Avatar answered Sep 18 '22 14:09

Young


To post a more complete answer, I had used a production version of php.ini which has display_errors = Off. Instead of turning it on globally, what I do now is, for files which I need error reporting on, I use ini_set('display_errors', 'On'); at the beginning of the file.

like image 20
ErJab Avatar answered Sep 18 '22 14:09

ErJab