Please enable JS

Enable Php to display errors on ubuntu.

img

Enable Php to display errors on ubuntu.

29 Mar 2020/ Yogesh

If you have freshly install ubuntu 16.04 or any version of ubuntu, and then installed fresh apache and php into the system then lets be frank, the error reporting has been turned off by default.

Then the first thing that we do is start our terminal type in php –ini and search for the php.ini file which tells us to be /etc/php/7.0/cli/php.ini and edit the ini file to display_errors. Then we restart the apache server.

But wait! did that solve the issue.

From first hand experience with the situation, that didnt solve anything. We still wont be able to see any php error. The basic step is somewhat misleading. The command php –ini tells us that the ini file is /etc/php/7.0/cli/php.ini , this ini file is for command line interface(cli) usuage of php and not the apache usuage, if you see the phpinfo you may see another picture. There you can see a line telling you that

Loaded Configuration File   /etc/php/7.0/apache2/php.ini

So the actual ini file that has been loaded is not /etc/php/7.0/cli/php.ini but /etc/php/7.0/apache2/php.ini.

So edit that ini file instead.

$ sudo gedit /etc/php/7.0/apache2/php.ini

There search for display_errors parameter and set

display_errors = Off  

to

display_errors = On

Also search for error_reporting parameter and set

error_reporting = E_All  &  ~E_DEPRECEATED ~E_STRICT

to

error_reporting = E_ALL

Finally save the file and restart apache.

The error should be displaying now.