简体   繁体   中英

Any .php file causing INTERNAL SERVER ERROR

Suddenly all .php files at my server causes INTERNAL SERVER ERROR.

I don't know if it's related, but it started while I was updating yum.

Even blank .php files will cause the error. I've moved ALL my website content and tryed only a empty .php file and still it gives the same error.

There's no .htaccess files also.

What should I do? =/

(Other sites at the same server are working fine)

Apache and php logs doesn't seem to be updating. Apache's last are from today, but there's nothing related to the issue. PHP's last are from APRIL

UPDATE

I just found each domain has its own Apache log.

Here what's in this particular site

[Thu Jul 28 22:04:02 2011] [error] [client 173.245.56.24] Premature end of script headers: cgi_wrapper
[Thu Jul 28 22:04:02 2011] [error] [client 173.245.56.168] suexec policy violation: see suexec log for more details
[Thu Jul 28 22:04:02 2011] [error] [client 173.245.56.168] Premature end of script headers: cgi_wrapper
[Thu Jul 28 22:04:02 2011] [error] [client 103.22.200.144] suexec policy violation: see suexec log for more details
[Thu Jul 28 22:04:02 2011] [error] [client 103.22.200.144] Premature end of script headers: cgi_wrapper
[Thu Jul 28 22:04:02 2011] [error] [client 103.22.200.150] suexec policy violation: see suexec log for more details
[Thu Jul 28 22:04:02 2011] [error] [client 103.22.200.150] Premature end of script headers: cgi_wrapper
[Thu Jul 28 22:04:03 2011] [error] [client 173.245.56.168] suexec policy violation: see suexec log for more details
[Thu Jul 28 22:04:03 2011] [error] [client 173.245.56.168] Premature end of script headers: cgi_wrapper
[Thu Jul 28 22:04:04 2011] [error] [client 199.27.128.138] suexec policy violation: see suexec log for more details
[Thu Jul 28 22:04:04 2011] [error] [client 199.27.128.138] Premature end of script headers: cgi_wrapper
[Thu Jul 28 22:04:04 2011] [error] [client 103.22.200.246] suexec policy violation: see suexec log for more details
[Thu Jul 28 22:04:04 2011] [error] [client 103.22.200.246] Premature end of script headers: cgi_wrapper

I am not sure, but sometimes it can be related to permissions of a file. On the web-host I use it will give a 505 if permission are not set to 655; 777 will give a 500 internal server error. My guess would be that in the PHP distribution update with YUM they did something similar, but this is only a guess. In short check the file permissions and if they are not 655 then try changing them to that.

Try reading the logs. Bare in mind that many hosting when they are overloaded they throw 500 Internal Server Error even if there's no problem with the php. It happens to my shared hosting account when I or somebody else in the same server overcharges it

If waiting for the server to became less busy or you see no logs then you should really talk to your hosting Support, this seem to be nothing to do with PHP itself, at least not on your side of it.

As found on https://support.exabytes.com/kb/a3479/500-internal-server-error-information.aspx :

Bad permissions, Writable by group

A bad permissions error may look something like this:

[Sun Jun 05 12:03:22 2012] [error] [client 66.249.72.82] SoftException in Application.cpp:601: Directory "/home/exampleuser/public_html" is writeable by group

In this instance the folder had permissions for a folder set too high. To correct this, the permissions need to be changed from "777" to "755".

Directories and folders should be 755. Executable scripts within the cgi-bin folder must be 755. Images, media, and text files like HTML should be 644.

Files - 644 CGI Scripts - 755 Directories - 755 You can modify permissions with the File Manager, located in the "Files" category of the cPanel, an FTP client, or using the chmod command in SSH/Bash.

Bad .htaccess, Invalid code, command, or syntax

In the .htaccess file ("dot htaccess"), you may have added lines that are either worded badly or conflicting. The best way to troubleshoot this is comment out the lines in the .htaccess.

You can comment out a line in the .htaccess by adding # to the beginning. You are wise to save an original copy of any file before you make changes.

For example, if the .htaccess looks like this:

DirectoryIndex default.html
AddType application/x-httpd-php5 php

Then try something like this:

DirectoryIndex default.html
#AddType application/x-httpd-php5 php

Broken lines and lines that start with php_flag are the most common mistakes. If you cannot determine which line is the problem, then comment out every line.

Other common .htaccess errors

FollowSymlinks

An error may look like the following:

[Sun Jun 05 12:07:10 2011] [alert] [client 66.249.72.82] /home1/examplec/public_html/.htaccess: Option FollowSymlinks not allowed here

In this example the error is simple to fix; in the file specified, use a permitted directive--in this case use "SymlinksIfOwnerMatches" instead of "FollowSymlinks", or remove the line entirely.

Syntax Not Closed

An error may look like the following:

 [Sun Jun 05 12:11:38 2011] [alert] [client 66.249.72.82] /home1/examplec/public_html/.htaccess: /home1/examplec/public_html/.htaccess:3: <IfModule>ExampleRule/Module> was not closed.

Again, the solution is to simply fix the syntax, or remove it. In this case, close the ending ""; directive properly and put the rules on their own line to resolve the problem.

These are just a few common examples that can be caused by bad .htaccess parameters. What you encounter will likely vary, however generally the error message is descriptive enough to determine an error from it without further investigation.

Improperly configured php.ini

ForceType

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).

An example: When you have a file called "item" (like Nucleus uses for FancyURL's) and want it to be parsed by the server as php you use the following code in your .htaccess file:

ForceType application/x-httpd-php

However, because our servers use phpsuexec this will result in an internal server error. To solve this you can simply use SetHandler instead of ForceType, so your .htaccess-file becomes:

SetHandler application/x-httpd-php

php_value

On a server without phpsuexec it is possible to use the php_value statement in a .htaccess file to change the settings of php (actually overwrite the settings from php.ini). On a sever with phpsuexec this will also result in a server error. To solve this you can use a php.ini file which you put in the same folder as where you would have put your .htaccess file. In that php.ini file you can change all the php values. You only have to put the values you want to modify in that file. By example if you want to set the short_open_tag to Off you would have used short_open_tag? = off in your .htaccess file. Using a php.ini file this results in:

[PHP]
short_open_tag = Off

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM