【发布时间】:2011-06-20 20:26:27
【问题描述】:
我在 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 将错误写入日志:
[2011 年 2 月 3 日星期四 17:35:13] -e: DBI 连接(':','',...)失败:访问 拒绝用户 'www-data'@'localhost' (使用密码:NO)在 lib/Connexion.pm 第 134 行
在我的浏览器中:
无法调用方法“prepare” lib/Search.pm 行的未定义值 51.
所以我知道脚本无法连接到数据库。但是为什么呢? 它正在处理 mod_cgi。 如果有人有想法:'( 谢谢。
【问题讨论】:
-
no use warnings;,在这里或在 Connexion 中会发现重复的 $var 问题
-
另外,正如其中一个答案所述,在 PerlOptions 中关闭 SetupEnv 会删除 mod_cgi 和 mod_perl 之间的一些兼容性
标签: perl web-applications cgi mod-perl2