Categories

Saturday, 26 May 2012

Internal server error in linux

When a site gives Internal Server Error on any Linux server I follow these steps:

NOTE: USER = username of account

Step 1:

cd /home/USER/public_html
find ./ -perm +022 | xargs chmod go-w

The above will remove world writable permissions from files/folders, which we do not need in suPHP.

Step 2:

cd /home/USER/public_html
find ./ -user nobody -print | xargs chown USER:USER

The above will change nobody owned files back to user.

Step 3:
cd /home/USER/public_html
find ./ -name .htaccess | xargs grep -i php_ /dev/null

The above command will search for any php_flag or php_value directive in .htaccess files. As we run suPHP so php_flag or php_value results in Internal Server Error if found.

Step 4 (edit by Avesta):
chmod 751 cgi-bin


If the files/folder names contain spaces or special characters then the above commands may give error. So in the case, try the following commands:

find ./ -perm +022 -print0 | xargs -0 chmod go-w
find ./ -user nobody -print0 | xargs -0 chown USER:USER
find ./ -name .htaccess -print0 | xargs -0 grep -i php_ /dev/null
find ./ -name .htaccess -print0 | xargs -0 grep -i AddType /dev/null

Example:

root@server [/home/USER/www]# find ./ -perm +022 | xargs chmod go-w
chmod: missing operand after `go-w'
Try `chmod --help' for more information.

root@server [/home/USER/www]# find ./ -user nobody -print | xargs chown stats.stats
chown: missing operand after `stats.stats'
Try `chown --help' for more information.

Such output means that there is no world writable file/folder or with nobody ownership. If there will be any  world writable file/folder or with nobody ownership then these commands will give no output.

If after running these commands you still see Internal Server Error, then the logs should be consulted. Logs that need to be checked are:

/usr/local/apache/logs/error_log
/usr/local/apache/logs/suphp_log

No comments:

Post a Comment

Ad