Updating, recompiling, VirtualHost templates, customizations,  php safemode …cgi files generate Internal Server Error

Updating, recompiling, VirtualHost templates, customizations,  php safemode …cgi files generate Internal Server Error This means that the cgi script did not execute properly.

There are several important causes that can generate mentioned error so a few things should  be checked.

1) check the /var/log/httpd/suexec_log.  It contain any errors that would be as a result of having no correct permissions on the file.  The file needs to be in a cgi-bin and must have its owner/group as the username for the who owns the site.  If it is own by anyone else, it will not run.

Also, the scripts must have execute permission.   and The most common chmod permission is 755.  Now Go through all directories from the public_html down to the directory the script is in, then make sure they’re all set to 755 (public_html can be 750 *only* if it has a group of apache).

If the suexec_log only is showing the script for being run, then the causes may be with that script code itself.  The easiest way for figuring out script coding problems is to first run the script manually from an ssh command prompt.

cd /home/username/domains/domain.com/public_html/cgi-bin
./script.cgi

Another common Server Error is to use an incorrect interpreter.  The 2 most common interpreters are:

#!/usr/bin/perl

and

#!/usr/local/bin/php

This code must be appear on the first line of that script.  Some time a file is uploaded in windows format so the trailing (return) newline character is forming incorrectly and the file will need to be reuploaded in a different format.

Other errors may would be generated when running the scripts manually from ssh then would be missing perl modules, in which case you will need to install them yourself.  Cpan is the easiest method to install new perl modules, eg:

perl -e shell -MCPAN
install Bundle::DBD::mysql

or

perl -MCPAN -e ‘install Bundle::DBD::mysql’

Running CGI script from any directory or via /~username/cgi-bin

Force apache In order to to allow cgi script to run, simply create a file call .htaccess inside the directory in which you wish to run the scripts.  Insert this text into the file:

Options +ExecCGI
AddHandler cgi-script .cgi .pl

Leave a Reply

Your email address will not be published. Required fields are marked *