500 Internal Server Error
"500 Internal Server Error" is a HTTP status code and usually indicates a server misconfiguration or problem with a script.
To check for configuration problems, rename any .htaccess file in the folder or ancestor folder of the problematic webpage. If you can access the resource after renaming an .htaccess file, then the .htaccess contains invalid entries. To figure out which configuration entries are causing the error, comment out sections until the error goes away, then uncomment sections until it returns. Once you've done this, look up the configuration directive(s) in Apache's documentation (or, if the directive configures an Apache extension, in the documentation for the extension) for the correct usage.
If a script causes a 500 response but other resources in the same folder can be accessed, check the following:
- The script and any parent directory shouldn't be world writable. Check the script's permissions using your FTP client or cPanel.
- Furthermore, PHP scripts shouldn't have executable permissions set.
- On the other hand, non-PHP scripts (not currently enabled on the free servers) must be executable as well as start with a shebang line referencing the correct interpreter.
- At a minimum, a script must generate a Content-Type header and a blank which ends the header section in order to comply with the CGI specification. PHP will generate the Content-Type header and ensure the blank line is present. Additional headers are allowed, but the blank line must be present. Absence of a blank line will cause a 500 response. Run the script from the command line of your own computer to check whether it generates a blank line after any headers.
- Error messages from script errors (such as syntax errors) may print in the header section, often causing a 500 response. If you get error messages when you run a script on your own computer, fix the errors and test the updated script. PHP will always finish the header section before printing error messages (which can cause other errors).
- Some text editors will insert a non-printing character called a "byte order mark" (BOM) at the start of a file. This character will interfere with shebang lines and, in PHP scripts, cause the body section to start immediately. Check the documentation for your text editor on how to safe files without a BOM.
- The X10 servers run Linux, which use the line feed character to separate lines, while Windows uses a carriage return+line feed. If you create or edit the file on a Windows box, the extra characters could interfere with the shebang line or cause syntax errors. To fix this, make sure your FTP client is set to transfer files in ASCII mode when you upload or download scripts, which will translate newlines. Modern FTP clients should switch automatically between ASCII and binary mode, or let you configure which files use ASCII mode, so you should only need to do this with old FTP clients or in unusual circumstances.