PHP errors NOT being displayed in the browser [Ubuntu 10.10]

PhpApacheApache2LampUbuntu 10.10

Php Problem Overview


I'm new to PHP and the whole LAMP stack but I've managed to get it up and running on my Ubuntu 10.10 system. Everything seems to be working with the exception of error reposting in the browser which I just can't seem to get working (and which I can't work without!).

I've read a number of article and other threads which indicate that the following values should be applied in the file /etc/php5/apache2/php.ini:

  • display_errors = On
  • display_startup_errors = On

I've restarted apache2 and even restarted my computer but for the life of me I just can't get it working. I've even tried using phpinfo() function which reports that these settings are as I've set them so I know it's picking up the correct configuration file but nothing!

Any help would be welcome.

Php Solutions


Solution 1 - Php

Don't just enable the first occurrence of display_errors in the php.ini file. Make sure you scroll down to the "real" setting and change it from Off to On.

The thing is that if you settle with changing (i.e. uncomment + add = On) by the very first occurrence of display_errors your changes will be overwritten somewhere on line 480 where it's set to Off again.

Solution 2 - Php

I had the same problem - solved it by setting display_errors = On in both php.ini files.

/etc/php5/apache2/php.ini
/etc/php5/cli/php.ini

Then restarting Apache:

sudo /etc/init.d/apache2 restart

Hope this helps.

Solution 3 - Php

To make it work you should change the following variables in your 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 & ~E_NOTICE
; Development Value: E_ALL | E_STRICT 
; 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

Search for them as they are already defined and put your desired value. Then restart your apache2 server and everything will work fine. Good luck!

Solution 4 - Php

After you edit /etc/php5/apache2/php.ini be sure to restart apache.

You can do so by running:

sudo service apache2 restart

Solution 5 - Php

  1. First you need to find the path to the php.ini file
  2. You will find the file in the specified path /etc/php/7.0/apache2/. If you are changing the values in the CLI folder or the CGI folder it will not work.
  3. Make the following changes

display_errors = On

  1. Restart you apache server

/etc/init.d/apache2 restart

Solution 6 - Php

If you have Local Values overriding master values, you won't change its values in php.ini take a look for those variables in a .htaccess or in the virtual-host config file.

...
        
        php_admin_value display_errors On
        php_admin_value error_reporting E_ALL
</VirtualHost>

If you edit vhost, restart apache,

$ sudo service apache2 restart

.htaccess edits don't need apache to restart

Solution 7 - Php

Follow the below steps,

1). Open your php.ini file via sublime through path 
    /etc/php/7.2/apache2/php.ini

2). find display_errors in that file

3). Un-comment these lines of code
      display_errors
      Default Value: On
      Development Value: On
      Production Value: Off

      display_startup_errors
      Default Value: Off
      Development Value: On
      Production Value: Off

      error_reporting
      Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
      Development Value: E_ALL
      Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT

      html_errors
      Default Value: On
      Development Value: On
      Production value: On

4). Save the file and then type the following command in the terminal
     sudo service apache2 restart


your errors are now showing in the browser

Solution 8 - Php

Use the phpinfo(); function to see the table of settings on your browser and look for the

> Configuration File (php.ini) Path

and edit that file. Your computer can have multiple php.ini files, you want to edit the right one.

Also check display_errors = On, html_errors = On and error_reporting = E_ALL inside that file

Restart Apache.

Solution 9 - Php

There are plenty of answers here on how to locate and modify your php.ini file, and generally, that is the best approach: set the correct settings in the server configuration.

But in some cases, when using shared hosting, you might not be able to modify your php.ini file, or, you may need to submit a support request to modify it, which you just do not have time for.

If you suddenly and immediately need to turn on errors in your erroring PHP script, without having to hunt down, modify the configs, and restart your server, then try this:

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

It seems clear what's happening above, but if you want to learn more:

Solution 10 - Php

Look at error_reporting directive in php.ini.

Solution 11 - Php

I was just stuck on the same issue, when I've realized that I was using the open short tag form:

<? echo 'nothing will be print if no open_short_tag option is enabled'; ?>

You have to go to your /etc/apache2/php.ini file and set the short_open_tag = Off to On, then sudo service apache2 restart!

Cheers!

Solution 12 - Php

it's should overlap, so it turned off. Try to open in your text editor and find display_errors and turn it on. It works for me

Solution 13 - Php

Try adding log_errors = Off and check the error_reporting setting whether it's set high enough.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionraven-kingView Question on Stackoverflow
Solution 1 - PhpdbmView Answer on Stackoverflow
Solution 2 - PhpAlexView Answer on Stackoverflow
Solution 3 - PhpsticksuView Answer on Stackoverflow
Solution 4 - PhpChrisCView Answer on Stackoverflow
Solution 5 - PhpCyborgView Answer on Stackoverflow
Solution 6 - PhpjuanmfView Answer on Stackoverflow
Solution 7 - PhpShahrukh AnwarView Answer on Stackoverflow
Solution 8 - PhpPhil RvView Answer on Stackoverflow
Solution 9 - PhpHoldOffHungerView Answer on Stackoverflow
Solution 10 - PhpduriView Answer on Stackoverflow
Solution 11 - Phpcl0udw4lk3rView Answer on Stackoverflow
Solution 12 - PhpKhakim GeekView Answer on Stackoverflow
Solution 13 - PhpCodeTwiceView Answer on Stackoverflow