Pregunta

He estado usando perlbrew para gestionar múltiples versiones de Perl en un Fedora Linux cuaderno. Lo he utilizado con gran beneficio para ejecutar secuencias de comandos de línea de comandos en su mayoría utilizando App :: cmd .

Ahora quiero pasar a la ejecución de aplicaciones web escritas usando CGI :: Application utilizando diferentes perlas instalados en mi $HOME. Estoy familiarizado con el funcionamiento de las aplicaciones web en Perl usando $HOMEs user_dir de Apache o la creación de máquinas virtuales, pero no estoy en condiciones de llegar a una forma limpia de la integración de éste y el perlbrew Perls gestionados. Específicamente necesito ayuda en la comprensión y la búsqueda de respuestas a estas preguntas:

  1. ¿Cómo instalar mod_perl bajo perlbrew?
  2. Suponiendo que esto se hace, cómo configuro mi host virtual para que se recoge el Perl correcto que es actual?
  3. Si esto no es posible, (cosa que dudo) puedo utilizar al menos las instalaciones locales para ejecutar la vainilla CGI ?

Gracias por su atención.

¿Fue útil?

Solución

I don't think this is a good use for perlbrew, which moves around symlinks under its own directory. The trick is switching the mod_perl module around. Remember, mod_perl is going to be binary-incompatible between major versions of perl, and that you will have to compile it against apache for each version of perl (and apache) you want to use.

perlbrew really does two big things for you:

  • Installs perl, which is trivially easy to do on your own.
  • Switches around symlinks so perl is whatever version you want.

If you give up on that last one, perlbrew isn't really doing that much for you. I don't think the symlink feature is particularly valuable.

I think perlbrew is fine for what it is, but when you start doing things outside of its limited scope, it's time to not use it. It's supposed to be a tool to save you some time and headache, so if it's not accomplishing that goal, it's not the right tool for your situation.

In this situation, where I'm supporting a single, big web application, I give it its own perl installation that I don't let anything else use.

For your other questions:

  1. markdown placeholder

  2. You shouldn't have to configure any VirtualHost stuff. If you are using mod_perl, perl is already in there and you don't get to choose a perl. If you're using CGI stuff, you specify the perl on the shebang line. You will have to ensure apache picks up the right library directories, but I think perlbrew handles that. You might have to use SetEnv or something similar in your httpd.conf.

  3. For vanilla CGI, just point to the right (symlink) path for whatever the default perlbrew version is. The CGI program will just use whatever perl that path points to.

Otros consejos

See brian d foy's answer for why not to expect to use perlbrew to switch between versions of mod_perl. I also expect that you will need to run multiple Apache servers, if you need multiple different Perl versions under mod_perl.

However, using perlbrew as an easy way to build Perl is IMHO a valid thing to do, and there are few instructions available for how to run mod_perl under perlbrew.

First ensure perl is built with shared library support, by passing the -Duseshrplib flag (otherwise on 64-bit systems you will get a confusing build failure about -fPIC):

perlbrew install perl-5.16.3 -Duseshrplib

Install the development Apache libraries for your system. On Debian, this differs depending on the Apache MPM that you are using. For the prefork MPM:

sudo apt-get install apache2-prefork-dev

Or for the worker MPM:

sudo apt-get install apache2-threaded-dev

Then you need some options to build and install mod_perl2 into the right place. Note that this means cpanm will fail to build it, but you could use it to get hold of the source:

cpanm mod_perl2  # fails
cd ~/.cpanm/latest-build/mod_perl-2.0.8/   # adjust mod_perl version

Adjust the version of Perl below accordingly. (The MP_APXS option is to give the right path for Debian-based systems, which you might not need.)

perl Makefile.PL MP_APXS=/usr/bin/apxs2 \
                 MP_AP_DESTDIR=$HOME/perl5/perlbrew/perls/perl-5.16.3/
make
make install

Finally, change the LoadModule line in your Apache configuration file (adjusting paths accordingly):

LoadModule perl_module <your homedir>/perl5/perlbrew/perls/<your perl>/usr/lib/apache2/modules/mod_perl.so

Your mod_perl installation will now be running the version of Perl that you want. Install all your required CPAN modules and get going.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top