The 500 Internal Server Error, which you may be seeing on the web console, may occur because of a random PHP file. 500 Internal Server Error may happen because of faulty .htaccess configuration, PHP memory limit, or a slew of other random issues.

I’ll show you how I normally debug and fix the 500 Internal Server Error for PHP files for most scenarios. Press F12 on Google Chrome and look at the Console tab to see if a PHP file is causing the 500 Internal Server Error.


In this example, a file called sharrre.php is giving me the 500 (Internal Server Error). Searching on Google and Stackoverflow will likely show you incorrect fixes because the 500 Internal Server Error can happen because of a variety of very different reasons.

Fixing the 500 Internal Server Error

500 Internal Server Error is shown when your PHP code produces a fatal error, but the error never states what the cause is! The best way to figure out what exactly is the cause of the error is to put a debugging statement in the PHP file.

The contents of a website deployed through Apache are served through website files inside /var/www/html.

cd /var/www/html

We want to change a file called .htaccess.

sudo vim .htaccess

We want to be able to display PHP errors, so we add a line to this file that allows us to display errors.

The important thing is to add php_flag display_errors 1.

Now, we want to make sure that visiting the PHP file that causes the error also shows debugging messages and the reason why the error occurs. For me, I’ll go to the place where sharrre.php is.

cd /var/www/html/wp-content/themes/anew/js
sudo vim sharrre.php

Inside the PHP file that causes the problem, I add:

Make sure that the above line is in between php tags like this:

After saving the changed file, visit the link of the PHP file.

I visit

I see a bunch of debugging statements that will help me figure out the cause of the 500 Internal Server Error.


You can ignore the Notice errors because they are more like warnings. But we can’t ignore Fatal error. The Fatal error says that I have a Call to undefined function curl_init(). The cause of the 500 Internal Server Error for me was that I was missing a PHP package called php5-curl on my Ubuntu web server! You will probably get a different Fatal error. My suggestion is to Google the fix for your specific error.

For my Call to undefined function curl_init(), all I have to do is install php5-curl.

sudo apt-get install php5-curl -y

After installing the php5-curl package, I should restart the apache2 server.

sudo service apache2 restart

After restarting the apache2 server, when I visit the page that was giving the 500 Internal Server Error, I don’t have the problem anymore. When I visit the PHP page that was causing me the problem, it actually works:


I open the web console on the page by pressing F12 on the web console.


Hurray! Now, I don’t have that potentially website breaking 500 Internal Server Error. Many people give different solutions to this 500 Internal Server Error, but debugging it yourself is the surest way to figuring out your unique solution to the problem.