[Mod_log_sql] mod-log-sql-mysql prevents CGI execution
Tom Van Vleck
thvv-gmane at multicians.org
Tue Aug 5 11:16:39 EDT 2008
Thomas Goirand <thomas at ...> writes:
> I'm the maintainer of the package in Debian. So far, I had no problem at
> all with CGI running mod_log_sql, and it's setup in all of our servers
> at GPLHost... You are giving too few details to be able to help.
Here is more detail on my problem with mod-log-sql and Apache.
What I did.
- (Apache was already set up by another sysadmin, and worked OK)
- installed mod-log-sql and mod-log-sql-mysql with apt-get
- configured it in apache2.conf and site config, and mods-enabled
- restarted Apache
- observed that hits are recorded in SQL
- executed a CGI - observed error 500, premature end of script headers
- deconfigured mod-log-sql in apache2.conf, site config, and mods-enabled
- restarted apache
- executed CGI - observed success code 200 and correct output
- unconfigured mod-log-sql in apache2.conf, site config, and mods-enabled
- deconfigured mod-perl in apache2.conf and mods-enabled
- restarted apache
- executed a CGI - observed error 500, premature end of script headers
Configuration data:
################################################################
Linux version: 2.6.24-18-server #1 SMP
Wed May 28 21:25:52 UTC 2008 i686 GNU/Linux
################################################################
Ubuntu version: 8.0.4
################################################################
Apache version:
ii apache2 2.2.8-1ubuntu0.3
ii apache2-mpm-prefork 2.2.8-1ubuntu0.3
ii apache2-utils 2.2.8-1ubuntu0.3
ii apache2.2-common 2.2.8-1ubuntu0.3
################################################################
mod-log-sql version:
ii libapache2-mod-log-sql 1.100-11.1
ii libapache2-mod-log-sql-dbi 1.100-11.1
ii libapache2-mod-log-sql-mysql 1.100-11.1
ii libapache2-mod-log-sql-ssl 1.100-11.1
################################################################
MySQL version: Server version: 5.0.51a-3ubuntu5.1 (Ubuntu)
################################################################
Apache config file (comments removed, site name changed):
ServerRoot "/etc/apache2"
ServerName "site.example.com"
LockFile /var/lock/apache2/accept.lock
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15
<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 150
MaxRequestsPerChild 0
</IfModule>
<IfModule mpm_worker_module>
StartServers 2
MaxClients 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
AccessFileName .htaccess
<Files ~ "^\.ht">
Order allow,deny
Deny from all
</Files>
DefaultType text/plain
HostnameLookups Off
ErrorLog /var/log/apache2/error.log
LogLevel debug
Include /etc/apache2/mods-enabled/*.load
Include /etc/apache2/mods-enabled/*.conf
Include /etc/apache2/httpd.conf
Include /etc/apache2/ports.conf
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\"
\"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
# ----------------------------------------------------------------
# remove these lines and disable mod-log* in mods-enabled to turn off mod-log-sql
LogSQLLoginInfo mysql://example:xxxxxxxx@192.168.1.100/databasename
LogSQLCreateTables on
LogSQLTransferLogFormat AbHhmRSsTUuvMq
LogSQLMachineID T11
# ----------------------------------------------------------------
ServerTokens Prod
ServerSignature On
AddHandler cgi-script .cgi
Include /etc/apache2/conf.d/
Include /etc/apache2/sites-enabled/
################################################################
Configuration of the enabled site (Comments removed, names changed):
NameVirtualHost 192.168.100.10:443
<VirtualHost 192.168.100.10:443>
ServerAdmin support at ipwizard.com
DocumentRoot /var/www/example
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/example>
# thvv add ExecCGI
Options -Indexes FollowSymLinks MultiViews +ExecCGI
#AllowOverride None
# thvv allow .htaccess 04/17/08
AllowOverride All
Order allow,deny
allow from all
</Directory>
<Files ~ (\.pl$)>
SetHandler perl-script
PerlResponseHandler ModPerl::PerlRun
Options +ExecCGI
PerlSendHeader On
</Files>
ErrorLog /var/log/apache2/error_example.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/ssl_access_example.log combined
ServerSignature On
# ----------------------------------------------------------------
# remove these lines and disable mod-log* in mods-enabled
# to turn off mod-log-sql
LogSQLTransferLogTable access_log
# ----------------------------------------------------------------
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/site.example.com.crt
SSLCertificateKeyFile /etc/apache2/ssl/extname.example.com.key
SSLCertificateChainFile /etc/apache2/ssl/intermediate.crt
SSLProtocol all
SSLCipherSuite HIGH:MEDIUM
</VirtualHost>
################################################################
CGI that fails if mod-log-sql is enabled, works if it is not enabled
#!/usr/bin/perl
# test file for debugging
# used to make sure we can access CGIs
print "Content-type: text/html\n\nhello world.\n";
################################################################
logs from apache
################################################################
ssl hit
68.44.62.222 - - [05/Aug/2008:15:47:04 +0100]
"GET /prod/cgi-bin/test1.cgi HTTP/1.1" 500 615 "-"
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US;
rv:1.9.0.1) Gecko/2008070206 Firefox/3.0.1"
68.44.62.222 - - [05/Aug/2008:15:52:53 +0100]
"GET /prod/cgi-bin/test1.cgi HTTP/1.1" 200 13 "-"
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US;
rv:1.9.0.1) Gecko/2008070206 Firefox/3.0.1"
################################################################
error.log
[Sun Aug 03 06:51:45 2008] [notice] Apache/2.2.8 (Ubuntu) mod_ssl/2.2.8
OpenSSL/0.9.8g mod_perl/2.0.3 Perl/v5.8.8
configured -- resuming normal operations
[Tue Aug 05 15:45:46 2008] [notice] caught SIGWINCH, shutting down gracefully
[Tue Aug 05 15:45:56 2008] [notice] Apache/2.2.8 (Ubuntu) mod_ssl/2.2.8
OpenSSL/0.9.8g mod_perl/2.0.3 Perl/v5.8.8
configured -- resuming normal operations
[Tue Aug 05 15:52:35 2008] [notice] caught SIGWINCH, shutting down gracefully
[Tue Aug 05 15:52:46 2008] [notice] Apache/2.2.8 (Ubuntu) mod_ssl/2.2.8
OpenSSL/0.9.8g mod_perl/2.0.3 Perl/v5.8.8
configured -- resuming normal operations
################################################################
site_error.log
[Tue Aug 05 15:47:04 2008] [error] [client 68.44.62.222]
Premature end of script headers: test1.cgi
################################################################
Declaration of access_log
CREATE TABLE `access_log` (
`id` char(19) default NULL,
`agent` varchar(255) default NULL,
`bytes_sent` int(10) unsigned default NULL,
`child_pid` smallint(5) unsigned default NULL,
`cookie` varchar(255) default NULL,
`machine_id` varchar(25) default NULL,
`request_file` varchar(255) default NULL,
`referer` varchar(255) default NULL,
`remote_host` varchar(50) default NULL,
`remote_logname` varchar(50) default NULL,
`remote_user` varchar(50) default NULL,
`request_duration` smallint(5) unsigned default NULL,
`request_line` varchar(255) default NULL,
`request_method` varchar(10) default NULL,
`request_protocol` varchar(10) default NULL,
`request_time` char(28) default NULL,
`request_uri` varchar(255) default NULL,
`request_args` varchar(255) default NULL,
`server_port` smallint(5) unsigned default NULL,
`ssl_cipher` varchar(25) default NULL,
`ssl_keysize` smallint(5) unsigned default NULL,
`ssl_maxkeysize` smallint(5) unsigned default NULL,
`status` smallint(5) unsigned default NULL,
`time_stamp` int(10) unsigned default NULL,
`virtual_host` varchar(255) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
################################################################
Declaration of scoreboard
CREATE TABLE `scoreboard` (
`id` int(14) NOT NULL auto_increment,
`vhost` varchar(50) NOT NULL default '',
`bytes_sent` int(14) NOT NULL default '0',
`count_hosts` int(12) NOT NULL default '0',
`count_visits` int(12) NOT NULL default '0',
`count_status_200` int(12) NOT NULL default '0',
`count_status_404` int(12) NOT NULL default '0',
`count_impressions` int(18) NOT NULL default '0',
`last_run` int(14) NOT NULL default '0',
`month` int(4) NOT NULL default '0',
`year` int(4) NOT NULL default '0',
`domain` varchar(50) NOT NULL default '',
`bytes_receive` int(14) NOT NULL default '0',
PRIMARY KEY (`id`),
UNIQUE KEY `vhost` (`vhost`,`month`,`year`,`domain`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
More information about the Mod_log_sql
mailing list