如何在OSX的httpd.conf覆盖@INC设置 [英] How to override @INC settings in httpd.conf on OSX

查看:164
本文介绍了如何在OSX的httpd.conf覆盖@INC设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何设置,其中的Perl会在Apache的httpd.conf文件模块上OSX?

How can I set where Perl looks for modules in Apache httpd.conf file on OSX?

我通过CPAN,这是在成功安装安装几个模块

I've installed several modules via CPAN, which were installed successfully in

/opt/local/lib/perl5/site_perl/5.8.9

我可以通过的perldoc perllocal

如果我在命令行中运行的perl -V ,我得到(其它迪尔斯中):

If I run perl -V on the command line, I get (among other dirs):

@INC:
  /opt/local/lib/perl5/site_perl/5.8.9/darwin-2level
  /opt/local/lib/perl5/site_perl/5.8.9

当我通过Apache运行perl脚本的CGI,但是,我得到的错误,我是模块使用 ING无法找到。被列入@INC显示目录列表中不符合我的本地Perl配置。

When I run a perl script as CGI via Apache, however, I get errors that the modules I'm useing can not be found. The list of dirs being included in @INC do not match my local perl configuration.

[error] [client 127.0.0.1] Can't locate Spreadsheet/ParseExcel.pm in @INC (
 @INC contains: 
     /Library/Perl/Updates/5.8.8 
     /System/Library/Perl/5.8.8/darwin-thread-multi-2level 
     /System/Library/Perl/5.8.8 
     /Library/Perl/5.8.8/darwin-thread-multi-2level 
     /Library/Perl/5.8.8 
     /Library/Perl 
     /Network/Library/Perl/5.8.8/darwin-thread-multi-2level 
     ...

如何运行的Perl作为OSX CGI时@INC越来越设置 - 和我怎么覆盖它。

How is @INC getting set when running perl as CGI on OSX - and how do I override it?

推荐答案

的初始值 @公司很难codeD时,的perl 构建,但它可以在许多方面进行修改。这里最方便的是

The initial value of @INC is hardcoded when perl is built, but it can be modified in a number of ways. The most convenient here are

SetEnv PERL5LIB ...

在Apache配置中,或者使用

from within the Apache configuration, or using

use lib qw( ... );

从Perl脚本中。

from within the Perl script.

这就是说,它不是安全使用使用Perl 5.8.9用Perl 5.8.8(尽管周围的其他方法是安全的)安装的模块。更糟糕的是,人们似乎是一个螺纹Perl和另一种是不。修改 @公司根本就没有去上班。

That said, it's not safe to use modules installed using Perl 5.8.9 with Perl 5.8.8 (although the other way around is safe). Even worse, one appears to be a threaded Perl and the other one isn't. Modifying @INC is simply not going to work.

您需要使用相同的安装模块 perl的如要使用运行脚本,或者必须使用相同的运行脚本一个 perl的作为一个用来安装该模块。

You need to install the module using the same perl as the one you intend to use to run the script, or you must run the script using the same perl as the one used to install the module.

这篇关于如何在OSX的httpd.conf覆盖@INC设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆