0

我在 CGI.pm 下开发了一个网络应用程序。我想切换到 mod_perl2。我的 webapp 在 CGI 下工作,但是当我尝试更改 mod 时,它不再工作,而我没有更改 webapp 中的任何内容,除了在 mod_perl 下运行的 apache conf 文件。

我已经安装了 mod-perl2 并像这样配置我的 VirualHost:

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>

我的脚本看起来像 . 他在 /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 在日志中写入错误:

[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 第 134 行

在浏览器中我有:

无法在 lib/Search.pm 第 51 行对未定义的值调用方法“prepare”。

所以我知道脚本无法连接到数据库。但是为什么呢?它正在处理 mod_cgi。如果有人有想法:'(谢谢。

4

2 回答 2

1

什么是 Connexion,它在 DBI 连接调用中做了什么?

您很可能不需要禁用 SetupEnv。

于 2011-02-03T18:49:28.903 回答
-1

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;
于 2011-02-03T21:25:47.923 回答