PHP - localhost is currently unable to handle this request. HTTP ERROR 500

79,229

You display_errors directive is set to no.

To fix this:

  1. Edit /etc/php/7.0/apache2/php.ini and 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: On
    
  2. Restart your apache with:

    sudo systemctl restart apache2
    
  3. To have the same behaviour on the cli edit the /etc/php/7.0/cli/php.ini

  4. To set this value locally add this to a .htaccess file in the server root: /var/www/html

Do

    vim .htaccess

Press i

Type the following:

    # Displaying php errors
    php_flag display_errors on
    php_value error_reporting 6143

Press
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:

  1. step 1 will change the master value, and

  2. step 4 will change the local value.

Share:
79,229

Related videos on Youtube

FreeKrishna
Author by

FreeKrishna

Coding is a more of a hobby than work (:

Updated on September 18, 2022

Comments

  • FreeKrishna
    FreeKrishna over 1 year

    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.

    HTTP 500 Error

    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?

    • George Udosen
      George Udosen over 7 years
      The value dispay_errors is off needs to be on...
    • George Udosen
      George Udosen over 7 years
      server root is /var/www for older versions of Ubuntu 14.04 -, and /var/www/html for Ubuntu 14.04 +, then sudo service apache2 restart is the old way for Ubuntu 14.04 and sudo systemctl restart apache2 is for` Ubuntu 16.04` but if you use sudo service for Ubuntu 16.04 it will still go.
  • FreeKrishna
    FreeKrishna over 7 years
    Thanks a lot @George , the first step worked for me. I still have a few doubts. When you say .htaccess file in server root, is it the /etc/apache2 directory? Also is there any difference between sudo systemctl restart apache2 and sudo service apache2 restart
  • George Udosen
    George Udosen over 7 years
    server root is /var/www for older versions of Ubuntu 14.04 -, and /var/www/html for Ubuntu 14.04 +, then sudo service apache2 restart is the old way for Ubuntu 14.04 and sudo systemctl restart apache2 is for Ubuntu 16.04 but if you use sudo service for Ubuntu 16.04 it will still go
  • Kulfy
    Kulfy about 5 years
    Can you please be a little bit more descriptive?