my browser show the content of my perl.cgi script instead of execute?

Ciprian Lungu picture Ciprian Lungu · May 31, 2012 · Viewed 8.7k times · Source

I recently update my Slackware13.37 using slackpkg and now firefox show the content of my perl.cgi script instead of execute. I am using:

bash-4.2# httpd -v 
Server version: Apache/2.4.2 (Unix) Server built: May 24 2012 14:55:44
bash-4.2# firefox -v 
Mozilla Firefox 12.0
bash-4.2# perl -v 
This is perl 5, version 16, subversion 0 (v5.16.0) built for i486-linux-thread-multi

the script works before update

#!/usr/bin/perl -w

use strict;
use warnings;
use CGI;
use DBI;
use PDF::API2::Simple;
use PDF::Table;
use Data::Types qw(:all);

my @param=();
###############################
###          main          ####
###############################
my $q = new CGI;
if(!defined $q->param('login')){
    if(!defined $q->param('query')){main::login_relogin('Welcome');
    }else{
    my ($fname,$lname,$sec,$w,$h) = main::read_cookie();
    if(defined $sec){
        main::home($fname,$lname,$sec,$w,$h,$q->param('query'),$q->param('param1'),$q->param('param2'));
    }else{main::login_relogin('Your session expired !!!');}
    }
etc... etc...

pls help

Answer

Thad picture Thad · Jun 11, 2012

I was having this same problem with Apache 2.4.2.

Problem solved: mod_cgi.so does not build by default on my system (openSUSE 12.1). When I built Apache 2.2, CGI was part of the core, not a dynamic module as in 2.4. So when running configure, adding --enable-cgi is needed. Also, uncomment "LoadModule dir_module modules/mod_cgi.so" in httpd.conf

Alternately, use mod_cgid.so, which did build on my system. Per http://httpd.apache.org/docs/current/mod/mod_cgi.html

"When using a multi-threaded MPM under unix, the module mod_cgid should be used in place of this module. At the user level, the two modules are essentially identical"

So, uncomment "LoadModule dir_module modules/mod_cgid.so" in httpd.conf. Also uncomment "Scriptsock logs/cgisock" in httpd.conf (in the directive).