2012-08-30 21 views
6

我想在我的web服务器上运行Catalyst应用程序,该服务器的系统为perl v5.10。我想至少使用v5.12作为应用程序,并且我不想干涉系统perl。在Web应用程序中使用非系统Perl的推荐方式是什么?

我们的系统管理员坚持认为,由非shell用户(例如“nobody”)运行

我知道我可以使用perlbrew来使用非系统perl进行开发,但我不确定什么是最好的方式来运行实时版本是。人们如何建议处理这种情况?

回答

4

nobody(即每个人)读取并执行perl可执行文件和所有库(在@INC目录下的所有内容)的权限。

将所有应用程序脚本中的shebang行(至少包括您的./scripts目录下的所有内容)更改为您要使用的perl实例。或者,如果您想灵活运用,请将shebang行指向符号链接,指向期望的可执行文件perl。确保此链接也可以通过nobody访问。

每当您将符号链接指向不同版本的Perl时,重新启动应用程序。

6

由于您熟悉perlbrew,您仍然可以使用它来安装Perl。

perlbrew install 5.16.1 --as=5.16.1t -Dusethreads 

你只要确保你给予适当的权限。说你$PERLBREW_ROOT/home/djh/perl5/perlbrew(默认):

chmod a+x /home/djh/ 
chmod a+x /home/djh/perl5/ 
chmod a+x /home/djh/perl5/perlbrew/ 
chmod a+x /home/djh/perl5/perlbrew/perls/ 
chmod -R a+rX /home/djh/perl5/perlbrew/perls/5.16.1t/ # Capital "X"!!! 

然后使用以下家当线在脚本:

#!/home/djh/perl5/perlbrew/perls/5.16.1t/bin/perl 

但也许你不希望它在你的家。如果是这样,你可以这样做:

cd /tmp 
wget http://search.cpan.org/CPAN/authors/id/R/RJ/RJBS/perl-5.16.1.tar.bz2 
tar xvjf perl-5.16.1.tar.bz2 
cd perl-5.16.1 
sh Configure -des -Dprefix=/opt/perls/5.16.1t -Dusethreads 
make test 

sudo mkdir /opt/perls/5.16.1t 
sudo chown djh:djh /opt/perls/5.16.1t 
make install 

安装程序将正确设置权限。所有你需要做的是设置家当来

#!/opt/perls/5.16.1t/bin/perl 

(“T”是我的螺纹建立约定。删除-Dusethreads如果你不想线程的支持。)

+0

@djh,加到我的答案。 – ikegami

相关问题