Search code examples
phplinuxfastcgiraspbianlighttpd

PHP5 - show errors


SOLUTION: Bunyamin's comment was my solution.

display_errors for php5-fpm not working with nginx

The second answer of that question mentioned the /etc/php5/fpm/pool.d/*.conf files, in my case /etc/php5/fpm/pool.d/www.conf

There I added

php_flag[display_errors] = on

and now it works.

QUESTION:

I have already turned on error reporting in the /etc/php5/cgi/php.ini file and no errors are shown.

If I add

error_reporting(E_ALL);
ini_set('display_errors', 1);

to my PHP code, all the errors are shown.

Why doesn't it work if I turn on error reporting in the php.ini files and don't add that code snippet? Shouldn't the php.ini file do the same as the code?

Webserver: Lighttpd OS: Raspbian Jessie

EDIT: phpinfo() shows that display_errors is set to Off, but in the php.ini file its turned On.

My php.ini file: http://pastebin.com/1qeK310n

Output of phpinfo(): http://www.file-upload.net/download-11264468/phpinfo.htm.html


Solution

  • I have four suggestions.

    First of all, make sure that you are editing the correct php.ini file. You can see which php.ini file is used with the function phpinfo().

    Simply create a file, phpinfo.php, with the following content. When you load the page (http://yoursite.com/phpinfo.php), you can see the details about your PHP configuration.

    <?php
        echo phpinfo();
    

    Secondly, make sure you set error_reporting to E_ALL to get full debug information (Suggested only in development).

    Thirdly, is there anywhere in your application that you set display_errors to 0. Sometimes, especially in frameworks, this property is set to 0.

    Lastly, sometimes Apache is configured in a way that a custom php.ini file located in the root directory of your webpage can override your global configuration. Then the change in global php.ini file would not affect your application.