ModPerl::RegistryPrefork should make my old cgi work but

412 views Asked by At

I developped a web app under CGI.pm.I'd like to switch to mod_perl2. My webapp worked under CGI but when i tried to change the mod, it's not working anymore while I didn't change anything in the webapp ,except the apache conf files to run under mod_perl.

I have installed mod-perl2 and configure my VirualHost like this :

Alias /project1/  /var/www/v6/cgi-bin/

PerlModule Apache::DBI
PerlModule ModPerl::RegistryPrefork

  <Directory /var/www/v6/cgi-bin/ >

        PerlOptions -SetupEnv
    SetHandler perl-script
    PerlResponseHandler ModPerl::RegistryPrefork
    PerlOptions +ParseHeaders
    Options +ExecCGI
    Order allow,deny
    Allow from all

  </Directory>

My script looks like . he uses some modules in /v6/cgi-bin/lib/

#!/usr/bin/perl 

    use lib qw(lib);
    use strict;
    use DBI;
    use CGI;
    use Template;
    use CGI::Carp qw(fatalsToBrowser);
    use Data::Dumper;

    use Connexion;
    use Search;

    my $cgi     = new CGI;

    our $fastdb = Connexion::database('1','1');
    my $get_description__id_sth  = Search->get_description_id_sth();

Apache2 write the error in the log :

[Thu Feb 3 17:35:13 2011] -e: DBI connect(':','',...) failed: Access denied for user 'www-data'@'localhost' (using password: NO) at lib/Connexion.pm line 134

In the browser i have :

Can't call method "prepare" on an undefined value at lib/Search.pm line 51.

So i understand that the script can't connect to the database.But why? It was working on mod_cgi. If someone has an idea :'( Thanks.

2

There are 2 answers

0
ysth On

What is Connexion and what is it doing in the DBI connect call?

You very likely need to not be disabling SetupEnv.

3
ZheFrench On

Connexion is a module i made for connecting my database.It's in /cgi-bin/lib whereas my previous script call him from /cgi-bin/ directory.

package Connexion;

use strict;
use DBI;
sub database{

    my ($var,$var) = @_;
    my ($host1 ,$user1,$dbname1 ,$pass1)= '';

    if (($var== 1) and ($var ==1)){

        $host1              = 'localhost';
        $user1              = 'root';
        $dbname1            = 'BASE';
        $pass1              = '**';
     }

return my $fastdb = DBI -> connect ('DBI:mysql:' . $dbname1 . ':' . $host1, $user1, $pass1);
}
1;