Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show errors in php on ubuntu?

Hello everyone I am really new to ubuntu? I just brought a new ubuntu 14 machine. I successfully installed apache2 and php5 but unable to see any warnings or error messages on the browser even though i am generating the errors to see them.

Every thing was working good on my old windows machine with XAMPP.

Now I have set the following values into /etc/php5/apache2/php.ini and /etc/php5/cli/php.ini

error_reporting = E_ALL | E_STRICT display_errors = On display_startup_errors = On

It does not show any errors until I use the following ini_set on each page ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);

P.S. - I have also used echo php_ini_loaded_file(); which shows /etc/php5/apache2/php.ini

Please help me :'(

like image 444
Cybersupernova Avatar asked Mar 19 '15 22:03

Cybersupernova


2 Answers

Check for the "loaded configuration file" in php.ini. If it is the same file then there must be some duplicate "display_errors = Off" line in your php.ini file in your bottom part. The later lines are always taken for execution. So search for all "display_errors" in your php.ini file and remove duplicates. And restart apache. Check phpinfo() output again to find about the "error reporting" variables.

like image 147
Prakash Shanmugam Avatar answered Oct 17 '22 14:10

Prakash Shanmugam


Here are the steps if you're dealing with PHP 7.4. You should be able to swap out the version number you're dealing with. Step 4 is probably the one you're missing.

  1. Create a file with the line php_ini_loaded_file(); in it.
  2. Visit that file. You should see something like /etc/php/7.4/fpm/php.ini
  3. Edit that file and find display_errors. Change the value to On
  4. Go to your terminal and run sudo service php7.4-fpm restart
like image 35
Pete Avatar answered Oct 17 '22 13:10

Pete