2

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

Ciprian Lungu
  • 300
  • 2
  • 14

2 Answers2

3

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).

Thad
  • 898
  • 13
  • 24
2

Basically, you need to tell Apache that the file is a script that needs to be run.

It's been a long time since I needed to do that, but unless things have changed drastically, you simply need to update your httpd.conf file, probably by marking your cgi-bin folder as a cgi-bin folder. It looks like the upgrade didn't do that automatically.

Max Lybbert
  • 19,717
  • 4
  • 46
  • 69
  • in the /etc/httpd/httpd.conf i found this line:"ScriptAlias /cgi-bin/ /srv/https/cgi-bin" – Ciprian Lungu May 31 '12 at 14:37
  • The other possibility is that the file isn't set as executable. Assuming you have `mod_cgi` correctly installed, the ScriptAlias should do things for you ( http://httpd.apache.org/docs/2.2/mod/mod_alias.html#scriptalias , but note the not about if the folder is already accessible from the web). – Max Lybbert May 31 '12 at 18:41