1

I just migrated my sites contents from Plesk to Cpanel on a CentOS 5.5 x64 LAMP VPS. The issue I am having is some php files work - others don't. For example, the current index.php file is working find and is running phpinfo() and giving results back - If I create a new test.php file and copy and paste the exact same code from index.php, it results in a 'Internal Server Error' message.

Can anyone provide any assistance with this? It's happening across all my domains and in one case, no php files are working.

Standard .html files all work so lead to believe something is wrong with my php install?

Example of 2 extracts from the log following:

A few extracts of the logs - "[Thu Oct 21 20:03:45 2010] [error] [client hidden] SoftException in Application.cpp:363: GID of script "/home/hidden/public_html/test.php" is smaller than min_gid [Thu Oct 21 20:03:45 2010] [error] [client hidden] Premature end of script headers: test.php"

"[Thu Oct 21 20:05:46 2010] [error] [client 80.255.223.242] SoftException in Application.cpp:431: Mismatch between target GID (507) and GID (10) of file "/home/trades/public_html/index.php" [Thu Oct 21 20:05:46 2010] [error] [client 80.255.223.242] Premature end of script headers: index.php"

6 Answers 6

1

I'm pretty sure this will turn out to be an suphp error. Check ownership differences between the working files and the erroring files and therein will lie enlightenment.

1
  • giving it a go now - frustrating!
    – user57833
    Oct 21, 2010 at 19:19
1

The group of /home/trades/public_html/index.php is different from the expected one. Check the expected group in /etc/group

cat /etc/group | grep 507 | awk -F":" {'print $1'}

and run

chgrp correct-group-name /home/trades/public_html/index.php

and then make sure permissions of this file and others under public_html are not higher than 755 and owner/group are

1

Sounds like your new server uses suPHP, while your old server did not. Also, you're been sloppy with your permissions and/or ownership. Here's a convenient little script to fix it. This particular code was off the top of my head, so I haven't tested it. Feel free to make corrections. The theory is sound, though: I use something similar to this frequently on clients servers.

Save it as a script, make it executable, and pass in the username you want to fix.

#!/bin/bash

die() { echo $* >&2; exit 1; }
USER=$1
# sanity checks
[[ -z $USER ]] && die "Please supply a user name"
[[ -d /home/$USER/public_html/ ]] || die "Username is not found"
[[ -d /home/$USER/tmp/ ]] || die "tmp dir not found... are you sure this is cpanel?"
G=$(stat --format=%G /home/$USER/public_html/)
[[ $G == "nobody" ]] || die "public_html not owned by group nobody? WTF?"

#change ownership of stuff
chown -R --reference=/home/$USER/tmp /home/$USER/public_html
chgrp nobody /home/$USER/public_html

#remove o/g write permission
chmod -R go-w /home/$USER/public_html

echo "You're all set, boss"
1

I solved the same problem, just take care of two points:

  1. php files permissions - 644 or 755 works
  2. php files owner and group - change user and group according with user account
0

Troubleshooting guide at: http://www.thecpaneladmin.com/tag/troubleshooting/

7
  • I could not get it to run on the test.php file (same internal error), but edited another php file that was working, added the code and it returned hundreds of errors for eacheval - "Parse error: syntax error, unexpected $end in /home/leitchy1/public_html/index2.php(9) : eval()'d code on line 1"
    – user57833
    Oct 21, 2010 at 15:31
  • Further error messages on another account, uploaded a Joomla install and all I get are "500 Internal Server Error The request was not completed. The server met an unexpected condition." messages regardless of what I do.
    – user57833
    Oct 21, 2010 at 15:33
  • @user57833 - Added the missing semicolon for the $end message - it sounds like there is an issue somewhere further up the request handling chain... what do your error logs look like?
    – danlefree
    Oct 21, 2010 at 15:34
  • Think I'm just going to start again and not migrate anything from Plesk - just do it manually - files and sql.
    – user57833
    Oct 21, 2010 at 15:40
  • @user57833 - I'd still recommend a review of the error logs (post them w/your question?) ... and you might also want to check the file ownership and permissions as those may be related to the issue (cPanel may not allow 777's to run and/or the file uid/gid may need to be within certain ranges).
    – danlefree
    Oct 21, 2010 at 15:49
0

You need to find a way to view the Php errors that are coming out. Are they being logged?

One technique is to try and run the script on the command line, then it may print the php error.

php -f <filename>

Another would be to edit test.php and change the error logging settings, for example turn on print errors or log the errors to a file somewhere in /tmp/

These can be very frustrating to resolve but once you are looking at what the php error is it should all flow from there. Your .htaccess or Apache config may explain why index.php is treated differently to test.php.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .