I'm currently trying to get php , apache and mysql up and running on Ubuntu. I've recently switched from Windows to Ubuntu to learn. But i'm facing a bit of a problem. When the code is correct the file gets executed properly in browser, where as when there is an syntax error, instead of showing the error in browser it throws an error as shown.
I've checked my php setting via phpinfo() and its as follows.phpinfo
I think error reporting is enabled, and I've tried reading similar other questions on the various threads,but they didn't really help me out. They pointed out that i need to verify that .htaccess file is in good shape. I'm not exactly sure how do i verify that, can anyone help me out? I've also tried changing directory permissions to 777 and 755 but that didn't help either. Any idea as to how can i fix it?
23 Answers
You display_errors directive is set to no.
To fix this:
Edit
/etc/php/7.0/apache2/php.iniand set:; display_errors ; Default Value: On ; Development Value: On ; Production Value: Off ; display_startup_errors ; Default Value: Off ; Development Value: On ; Production Value: Off #to ; display_errors ; Default Value: On ; Development Value: On ; Production Value: On ; display_startup_errors ; Default Value: On ; Development Value: On ; Production Value: OnRestart your apache with:
sudo systemctl restart apache2To have the same behaviour on the
cliedit the/etc/php/7.0/cli/php.iniTo set this value locally add this to a
.htaccessfile in the server root:/var/www/html
Do
vim .htaccessPress i
Type the following:
# Displaying php errors php_flag display_errors on php_value error_reporting 6143Press
Esc
:x
Enter
Note:
Mine was php version 7.0. Change to your particular version. And in your image both local and master values are both set to Off so:
step 1will change themaster value, andstep 4will change thelocal value.
You just need to add following lines of code to your PHP file for temporary configuration
error_reporting(E_ALL);
ini_set('display_errors', 1); you can fix now this way
1 : /etc/php/7.0/apache2/php.ini
2: ; error_reporting Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED Development Value: E_ALL Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT 3 : sudo systemctl restart apache2
1