簡體   English   中英

mod_perl處理包含路徑的方式與cgi不同?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM