This article describes ways to minimize the occurrence of "500 Internal Server Error" messages.
Table of Contents
- Problem
- Resolution
- Set correct permissions
- Check .htaccess directives
Problem
Visitors to your web site receive “500 Internal Server Error” messages when they access a page that uses PHP.
Resolution
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
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 othersThese 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. If you have a shared hosting account, our Guru Crew can change the owners and groups for your files. If you need further assistance, please open a support ticket with our Guru Crew on the Customer Portal at //my.a2hosting.com.
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:
Do not change permissions on the public_html directory itself! Doing so may make your web site inaccessible.
Check .htaccess directivesServers 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 configurationTo resolve this problem, you must place any PHP directives into a custom php.ini file on your account, and remove or comment out any PHP directives in the .htaccess file. For information about how to set up a custom php.ini file, please see this article.
btw apa tuh permision 777
maaf newbie
ini ada kode php lo mau cmod otomatis
yang akan mencmode sebuah folder beserta sub folder
sekaligus files dalam folder
Catatan:
ganti pada
bagian " rchmod('folder/', 0755, 0644); "