Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

500 Internal Server Error for php file not for html [duplicate]

My site having 4-5 static pages only. index.html & index.php both are there. index.html is working fine. If I change to index.php, it's giving 500 Internal Server Error. I don't know where is my mistake?

Note: If I use .htaccess file with php_flag display_errors 1,

It's showing Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

If I use .htaccess file with empty,

It's showing Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

And if I give ../contact-us.php, it's showing correctly.

Thanks...

like image 852
KarSho Avatar asked Jul 17 '13 07:07

KarSho


People also ask

What causes 500 errors PHP?

PHP Coding Timing Out If your PHP script makes external network connections, the connections may time out. If too many connections are attempted and time out, this will cause a "500 Internal Server Error." To prevent these time outs and errors, you'll want to make sure that PHP scripts be coded with some timeout rules.

How can I make PHP display the error instead of giving me 500 Internal server error?

Check the error_reporting , display_errors and display_startup_errors settings in your php. ini file. They should be set to E_ALL and "On" respectively (though you should not use display_errors on a production server, so disable this and use log_errors instead if/when you deploy it).

How to check for 500 Internal Server Error in PHP?

Check your logs ( /var/log/apache/error.log or /var/log/httpd/error.log, most likely); but I'd guess your PHP file has an error. 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...

What are the common server-side errors in PHP?

Most 500 errors are server-side errors. Permission Error : Check permission of files and folders. In most of those cases, an incorrect permission on a PHP and CGI script is to blame. The permission should be set at 755.

Why is my page displaying an internal server error in PHP?

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.

What are the side effects of PHP running as CGI?

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.


1 Answers

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 
like image 93
Hast Avatar answered Sep 24 '22 00:09

Hast