How can I install Perl modules on a restricted server?

馋奶兔 提交于 2019-12-12 14:40:16

问题


I have a server that I can ssh into but that's it. Otherwise it is totally closed off from the outside world. I'm trying to deploy some scripts I wrote to it but they have several Perl dependencies (Params::Validate, XML::Simple, etc.) I can't get them via yum since our satellite server doesn't have those packages and the normal CPAN install won't work either since the host is so restricted. Moving the module sources over and compiling is extremely tedious. I've been doing that for over a day, trying to resolve dependencies, with no end in sight. Is there any way around this? Any help is greatly appreciated.


回答1:


If you can, set up a parallel system as close as possible (as far as architecture, and perl version) to your closed system, and install all your dependencies there into a separate lib directory using local::lib. Then you can simply scp over that directory to your closed system, and again using local::lib (and setting up some environment variables), your code will be able to utilize that directory.




回答2:


See this, it explains multiple methods that you can use to get CPAN modules into production.




回答3:


Have you tried cpan minus? If not, here's how to get it.

curl -L http://cpanmin.us | perl - App::cpanminus

You can use it with local::lib. :-D

Chromatic has a great post on how to even get a newer(and multiple) version(s) of perl onto a restricted system.




回答4:


If you can change your hosting provider, this would be a good time to switch ;-) (I personally think Linode rocks!).

Assuming that is not the case, you can try to go with the option of setting a parallel system as @Ether suggested.

On the other hand, if the modules you are using and their dependencies are pure Perl modules, you should be able to use PAR::Packer to package your script and its dependencies and scp a single file over to the host.




回答5:


I use SSH tunneling to tunnel from the remote server back to a local proxy server. That way you can install whatever Modules you need. Just set the http_proxy variable to the local port that is remote forwarded (If that makes sense) from your local machine.

i.e.

ssh user@remote -R 3128:proxy_ip:3128  (for a tunnelling a Squid setup)

then on the remote server in cpan

o conf http_proxy=http://localhost:3128
o conf commit


来源:https://stackoverflow.com/questions/3206035/how-can-i-install-perl-modules-on-a-restricted-server

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!