These are some things to check if you're having a problem getting a CGI script running.
Info: Check the Error Log
Check the error log for the server to see if there's anything there. Remember that a code error will result in a “500 Internal Server Error”. The real error output will be in the error log.
tail /var/log/apache2/error.log
tail /var/log/apache2/suexec.log
File Permissions
The file and directory permissions have to be right for the suEXEC wrapper to do its thing. It's very particular about the owner and permissions of the script and directory that contains it. Usually the problem is file permissions, which can be fixed as follows:
chmod 0755 script.cgi
chmod 0755 ~/public_html
Make sure it can run
A CGI script can be executed like any other program. It might generate errors because no CGI data is received, but it should at least start to run.
./script.cgi
A “bad interpreter” error can be caused by a problem interpreting a DOS-format text file. You can convert the file to a Unix text file with the dos2unix
command:
dos2unix script.cgi
Turn on ExecCGI
A “403 Forbidden” error can be caused by not having the ExecCGI
option on for the directory. Add this line either to your .htaccess
file, or to the directory configuration elsewhere:
Options +ExecCGI
Turn on CGI Handling
If the file is being served as static content instead of being executed (i.e. you see the code, not its output), then the cgi-handler
handler is probably not being used for this resource.
AddHandler cgi-script .cgi