Reputation: 416
I have installed additional versions of Perl on a Fedora 21 system. On the PATH, my custom Perl (5.10.0) has priority over the distro's default Perl (5.18.4)
user$ perl -v
> This is perl, v5.10.0 built for x86_64-linux
root# perl -v
> This is perl, v5.10.0 built for x86_64-linux
However, when printing the Perl version in a script served by Apache, it appears to be using the "wrong" version:
5.018004
How can you direct Apache to use a specific version of Perl?
Upvotes: 3
Views: 1174
Reputation: 1735
When using plain CGIs, the OS (through the #! line) is responsible for picking the interpreter. As we have established, the shebang was pointing to the wrong version of the interpreter.
The easiest way is to edit it. If you need the same script to work with two different perl versions depending on the call context, you can use something like #!/usr/bin/env perl
in the shebang to have it respect the environment, then change the PATH
variable for apache.
If you cannot edit the shebang, there is the option of going through mod_perl
(make sure you compile it against the desired version) if you don't mind using this specific version for the whole webserver.
Another way would be to run the webserver within some kind of container (chroot, lxc, docker, or just using mount namespaces) so that your /usr/bin/perl
points to some other version of the interpreter.
Upvotes: 2