≡ Menu

Getting 500 Internal Server Error on PHP pages

The question – When I try to visit my PHP pages using a browser, I get a 500 internal server error. What could be the problem?

A 500 internal server error can be caused by several reasons, some of which I describe below. The error means that something went wrong with the web server which is not a result of just a syntax error.

In most cases, a 500 error is caused because of a syntax error in the .htaccess file. The .htaccess file is specific to directories. So, try to open PHP pages in another directory and if there is no 500 error, you have just confirmed that the error is because of the .htaccess file.

Also, check the error_log file of Apache. First locate your log files:

[root@server ~]# httpd -V
Server version: Apache/2.2.15 (Unix)
Server built:   Aug 13 2013 17:27:11
Server's Module Magic Number: 20051115:25
Server loaded:  APR 1.3.9, APR-Util 1.3.9
Compiled using: APR 1.3.9, APR-Util 1.3.9
Architecture:   32-bit
Server MPM:     Prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D HTTPD_ROOT="/etc/httpd"
 -D SUEXEC_BIN="/usr/sbin/suexec"
 -D DEFAULT_PIDLOG="run/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="logs/accept.lock"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"
[root@server ~]#

So the above output tells me that the error_log file is located in the following location:


Open and inspect the error_log file thoroughly and check for errors.

Another reason for a 500 error could be that you are running out of disk or swap space.

To check if you are running out of disk space, run the following commmand:

[root@server ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/simfs             25G  1.1G   24G   5% /
none                  256M  4.0K  256M   1% /dev
[root@server ~]#

You may be running out of swap space and disk space both:

To check your swap space usage, use the free command:

[root@server ~]# free -mt
             total       used       free     shared    buffers     cached
Mem:           512        125        386          0          0          0
-/+ buffers/cache:        125        386
Swap:            0          0          0
Total:         512        125        386
[root@server ~]#

If everything looks OK and you still get the 500 error, look for system messages in the following log file:


{ 0 comments… add one }

Leave a Comment