User Tools

Site Tools


apache:troubleshooting:script_execution_problems

Apache - Troubleshooting - Script execution problems

The Apache mod_cgi module allows scripts to be executed during the request processing stage.

CGI script can be written in numerous scripting languages, and allow content to be dynamically created for clients.

When errors occur with a script executing inside mod_cgi, determining why the script failed to run can pose a number of challenges.

One way to debug script execution problems is with the mod_cgi ScriptLog directive.

  • When ScriptLog is enabled, mod_cgi will log the output from each CGI script that did not execute properly.
  • This output contains the server response code, the request that was received, the response that was sent to the client (if anything was sent at all), and is a great debugging tool when script errors are produced in the error_log, or when a user complains that something is not working properly.

To enable CGI script error logging, the ScriptLog directive and the location of a log file to write errors to can be added to the Apache configuration file.

Once ScriptLog is enabled, mod_cgi will produce log file entries similar to the following each time a script fails to execute properly:

%% [Wed Feb 28 11:12:13 2016] GET /cgi-bin/print HTTP/1.1
%% 500 /var/tmp/apache/cgi-bin/print
%request
Accept: */*
Accept-Language: en
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/418.9.1 (KHTML, like Gecko) Safari/419.3
Connection: keep-alive
Host: 192.168.1.69:8080
%response
Script /cgi-bin/print
%stdout
Script Location /var/tmp/apache/cgi-bin/print

NOTE: For busy websites and where there are concerns with how much storage the log file may consume, the ScriptLogLength directive can be used to enforce an upper bound on the size of the log.

apache/troubleshooting/script_execution_problems.txt · Last modified: 2021/02/02 09:46 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki