2014-06-17 25 views
0

错误日志:如何使用perlbrew w/Apache来提供CGI脚本?

[Tue Jun 17 12:08:35 2014] [error] [client 172.18.40.199] Perl v5.16.0 required--this is only v5.10.1, stopped at index.cgi line 2. 
[Tue Jun 17 12:08:35 2014] [error] [client 172.18.40.199] BEGIN failed--compilation aborted at index.cgi line 2. 
[Tue Jun 17 12:08:35 2014] [error] [client 172.18.40.199] Premature end of script headers: index.cgi 

这是运行作为用户:“支持”和支持perlbrew W /开关设置为5.16.3运行,如下图所示:

# su - support 
print() on closed filehandle $fh at /loader/0x1cb94a8/App/perlbrew.pm line 19. 
-bash-4.1$ perl -v 

This is perl 5, version 16, subversion 3 (v5.16.3) built for x86_64-linux 

我需要做什么来如何确保Apache执行index.cgi w/perlbrew安装的perl?

回答

2

操作系统执行由要求执行的脚本shebang(#!)行标识的解释器(index.cgi)。这只是一个指定您在那里使用perlbrew安装的解释器的路径的问题。

执行which perl(更熟悉)或perl -E'say $^X'(更可靠?)来确定所需的值。


我们来举个例子。

对我的机器之一,我使用我的线程版本5.18.2时得到以下内容。 (你会得到不同的东西。)

$ which perl 
/home/ikegami/usr/perlbrew/perls/5.18.2t/bin/perl 

$ perl -E'say $^X' 
/home/ikegami/usr/perlbrew/perls/5.18.2t/bin/perl 

所以我用以下为index.cgi第一行:

#!/home/ikegami/usr/perlbrew/perls/5.18.2t/bin/perl 
0

index.cgi中是否有shebang?它指向哪个Perl?

我相信shebang应该指向你的自定义perl而不是你已经显示的系统perl。

+0

#在/ usr/bin中/ perl的 使用v5.16!; 使用严格; 使用警告; – morissette

+0

这不提供问题的答案。要批评或要求作者澄清,请在其帖子下方留言。 – vonbrand

+0

@ vonbrand,答案并不完全是高质量,但它确实回答了这个问题。把第一段作为修辞问题。 – ikegami

2

使用适当的Perl/bash的家当..

以下将工作完全

#!/bin/bash 
export PERLBREW_ROOT=/opt/perlbrew 
export PERLBREW_HOME=/tmp/.perlbrew 
export SHELL=/bin/bash #not really needed 
unset XTERM_SHELL #not really needed 
source ${PERLBREW_ROOT}/etc/bashrc 
perlbrew use perl-5.21.9 > /dev/null 2>&1 # you can add your version here... 
eval 'exec perl -x -wS $0 ${1+"[email protected]"}' if 0; 
#! -*-perl-*- 
# line 10 The above line/string resets the perldebug line-numbering... 
print "The perl interpretter running this code is $^X\n" ; 
print "This is perl version $^V\n" ; 
print "Hello PerlBrew \n" ; 
die "This should be line number 14\n" ; 
print "x\n" ; 

,这将导致...

The perl interpretter running this code is /opt/perlbrew/perls/perl-5.21.9/bin/perl5.21.9 
This is perl version v5.21.9 
Hello PerlBrew 
This should be line number 14 

希望这有助于...