Fixing 500 Internal Server Error.

This article describes ways to minimize the occurrence of "500 Internal Server Error" messages.

Almost all of our servers run PHP as a CGI binary. One of the side effects of running PHP as a CGI binary is that internal server errors can occur if the permissions on files and directories are set incorrectly. Internal server errors can also occur if there are certain PHP directives defined in an .htaccess file.

If your web site is experiencing internal server errors, the first thing you should do is check the server logs. The server logs provide valuable information about which files are causing the errors, and potential causes. If you have a shared hosting account, you can view your web site's error logs in cPanel. If you have a VPS or dedicated server, you can view your web site's log files directly at the following paths:
  • /usr/local/apache/logs/error_log
  • /usr/local/apache/logs/suphp_log
Set correct permissions
If permission settings are causing internal server errors, you may see entries in the server logs similar to any of the following lines:
SoftException in Application.cpp:357: UID of script "/home/username/public_html/.htaccess" is smaller than min_uid

SoftException in Application.cpp:146: Mismatch between target UID (511) and UID (510) of file "/home/username/public_html/index.php"

SoftException in Application.cpp:256: File "/home/username/public_html/index.php" is writeable by others
These errors are all caused by permission issues. The first two lines indicate that the file's owner or group is set incorrectly. For example, if the owner of a PHP file is the nobody or root account instead of your user account, visitors receive an internal server error when they try to view the page.

The third line indicates that file permissions for the index.php file are too permissive. For example, if your web site has a directory or file whose permissions are set to 777 (full permissions), anyone can read, write, or execute it. Additionally, visitors receive an internal server error when they try to view the page. To resolve this problem, change the permissions to 755 for directories and 644 for files. For example, to set the correct permissions for all directories and files in the public_html directory, type the following commands:
cd public_html
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;

Do not change permissions on the public_html directory itself! Doing so may make your web site inaccessible.

Check .htaccess directives
Servers that run PHP as a CGI binary cannot use the php_flag or php_value directives in an .htaccess file. If directives in an .htaccess file are causing internal server errors, you will see entries in the server logs similar to the following line:
/home/username/public_html/.htaccess: Invalid command 'php_flag', perhaps misspelled or defined by a module not included in the server configuration
  • 0 Users Found This Useful

Was this answer helpful?

Related Articles

Fixing PHP Fatal Error: Allowed Memory Size Exhausted.

A common error with open source software like WordPress, Moodle, and Joomla is the PHP "Allowed...

Monitor WordPress PHP Errors

Close monitoring of your site’s PHP errors is crucial to operating a healthy, secure, and...

PHP Ownership/Permission Issues.

"Bad File Descriptor" Errors in FTP*Note that this applies to servers running mod_php only* As...

Turning On PHP Errors.

For security reasons, most web servers have PHP errors turned off. This makes sense on live sites...

Important info about cookies. By browsing our website or closing/agreeing this message,
you consent to the use of cookies as described in our Cookie Policy.

I Agree

whmcs modules