[英]mod_perl handles inclusion paths differently than cgi?
我有一个用perl编写的脚本,并作为CGI执行。 它工作正常。 最近我将mod_perl模块安装到apache中,并使用了PerlModule ModPerl :: Registry指令。
PerlModule ModPerl::Registry
PerlModule CGI
PerlSendHeader On
Alias /perl/ /real/path/to/perl/scripts/
<Location /perl>
SetHandler perl-script
PerlHandler ModPerl::Registry
Options ExecCGI
</Location>
<Files *.perl>
SetHandler perl-script
PerlHandler ModPerl::Registry
Options ExecCGI
</Files>
我已经读过使用这个我不需要修改我的cgi perl代码。 (我总是使用严格的编译指示,所以不要担心未初始化的全局变量和类似的东西)。
我的原始脚本仍然按预期工作,除了一件事,我在require()函数中包含的文件无法再解析。
script.cgi:
#!/usr/bin/perl -w
use strict;
use CGI qw(:standard Vars);
require "includes/functions.cgi";
#blah blah, more stuff
script.perl
#!/usr/bin/perl -w
use strict;
use CGI qw(:standard Vars);
require "includes/functions.perl"; # <---- Returns error: Can't locate includes/functions.perl in @INC
#blah blah, more stuff
目录结构的工作方式如下:
$ ls
script.cgi script.perl包含/
$ ls包括/
functions.cgi functions.perl
来自: http : //perl.apache.org/docs/2.0/api/ModPerl/Registry.html
META:文件说现在我们没有chdir()进入脚本的目录,因为它会影响线程下的整个进程。 ModPerl :: RegistryPrefork应该由只在prefork MPM下运行的人使用。
所以,如果你使用Apache2的prefork MPM,你应该尝试使用ModPerl :: RegistryPrefork。 如果你正在使用worker,event或windows,你将不得不改变你的程序,不要假设cwd是perl所在的目录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.