This question already has answers here:
500 Internal Server Error is shown if your php code has fatal errors but error displaying is switched off. You may try this to see the error itself instead of 500 error page:
In your php file: ini_set('display_errors', 1);
In .htaccess file: php_flag display_errors 1
How To Fix HTTP Error 500 Internal Server Message For example, if the owner of a PHP file is the nobody or root account instead of your user account, visitors HTTP Error 500 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.
A PHP file must have permissions set to 644. Any folder containing PHP files and PHP access (to upload files, for example) must have permissions set to 755. PHP will run a 500 error when dealing with any file or folder that has permissions set to 777!
Learn how to fix the HTTP error code “500 internal server error” on your Linux Server running Apache. If you are not sure what is causing the error, you can follow the error log in one window and watch it being Customize this line to add the extension your files are using (.py, .php, .pl, etc.). <Directory "/var/www/html">. On PHP 5.5 => "header("tester.php",true,500);" where tester.php does not exist. It works and takes me to my 500 page :) Unfortunately none of the other methods listed here worked for me for one reason or the other.
I know this question is old, however I ran into this problem on Windows 8.1 while trying to use .htaccess files for rewriting. My solution was simple, I forgot to modify the following line in httpd.conf
#LoadModule rewrite_module modules/mod_rewrite.so
LoadModule rewrite_module modules/mod_rewrite.so
Restarted the apache monitor, now all works well. Just posting this as an answer because someone in the future may run across the same issue with a simple fix.
Why am I getting Server 500 errors with php scripts? Specific statements in your .htaccess file may result in an error 500 (internal server error). file to make it clear to the server how to handle that file (or all the files in the folder) (this works on servers without phpsuexec). How to customize your html or php error pages. When you are using files with (or without) an extension different then the normal extension for that filetype you can use ForceType in your .htaccess file to make it clear to the server how to handle that file (or all the files in the folder) (this works on servers without phpsuexec).
I was having this problem because I was trying to connect to MySQL but I didn't have the required package. I figured it out because of @Amadan's comment to check the error log. In my case, I was having the error:
Call to undefined function mysql_connect()
If your PHP file has any code to connect with a My-SQL db then you might need to install
php5-mysql first. I was getting this error because I hadn't installed it. All my file permissions were good. In Ubuntu, you can install it by the following command:
sudo apt-get install php5-mysql
500 Internal Server Error is shown when your PHP code produces a fatal Apache are served through website files inside /var/www/html . Troubleshoot as a 504 Gateway Timeout error instead. It's not very common, but some servers produce a 500 Internal Server Error when in reality 504 Gateway Timeout is a more appropriate message based on the cause of the problem. Contacting the website directly is another option.
It was changing the line endings (from Windows CRLF to Unix LF) in the
.htaccess file that fixed it for me.
A 500 Internal Server Error can be caused by many things, including but not limited lines in your php.ini or .htaccess file, invalid requests in the script, and others not mentioned here. Images, media, and text files like HTML should be 644. A PHP file must have permissions set to 644. Any folder containing PHP files and PHP access (to upload files, for example) must have permissions set to 755. PHP will run a 500 error when dealing with any file or folder that has permissions set to 777! share. Share a link to this answer.
Are you seeing a 500 internal server error when trying to access your WordPress site? Not to mention it simply looks bad for your brand. Corrupted files in your WordPress installation. The server takes this request, processes it, and sends back the requested resources (PHP, HTML, CSS, etc.) Finally, because 500 internal server errors can also occur from PHP timing out or fatal PHP errors with third-party plugins, you can always check with your WordPress host. Sometimes these errors can be difficult to troubleshoot without an expert.
In this KB you will learn on how to resolve 500 internal server error easily. PHP error reporting by adding the following lines to the index.php file: take a look at it if you're not able to work out what's happening on your own). The 500 error code is a generic message that appears when something unexpected happened on the web server and the server can’t offer more specific information. Rather than giving you a normal web page, an error occurred on the web server and the server gave your browser a web page with an error message instead of a normal web page.
Comments Are you typing /index.php into your address-bar or did you actually change the directory-index to index.php? Also please post the code contained in the index.php file! Check your logs (
/var/log/httpd/error.log, most likely); but I'd guess your PHP file has an error.
may your php code have some errors 500 Internal Server Error is generic, the real cause is hidden in your server logs. I think this related to file permission, can you check other PHP file permission and compare with the one that you renamed... @KarSho check this out: stackoverflow.com/questions/11179706/… you save my day just want to point out that .htaccess file is present in your project root. if it isn't , simply create a new file and rename its extension How would one change those permissions? Changing all the files permission to 755 and also the main folder to 755 Solve the problem for me Yep, that was the 500 error. It's gone now. This answer needs more upvotes! What did the trick for me: set both group and owner of index.php as the Apache user, mine was nobody for group! @JCMcRae to change permissions is simply : chmod 644 <path/file>.php