2014-06-17 27 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 

希望這有助於...