Perl Programming Page 3 - Introduction to mod_perl (part 3): Non-privileged Install |
Now when we have learned how to install local Apache and Perl modules separately, let's see how to install mod_perl enabled Apache in our home directory. It's almost as simple as doing each one separately, but there is one wrinkle you need to know about which I'll mention at the end of this section. Let's say you have unpacked the Apache and mod_perl sources under /home/stas/src and they look like this: where x.xx are the version numbers as usual. You want the Perl modules from the mod_perl package to be installed under /home/stas/lib/perl5 and the Apache files to go under /home/stas/apache. The following commands will do that for you: If you need some parameters to be passed to the .configure script, as we saw in the previous section use APACI_ARGS. For example: Note that the above multiline splitting will work only with bash, tcsh users will have to list all the parameters on a single line. Basically the installation is complete. The only remaining problem is the @INC variable. This won't be correctly set if you rely on the PERL5LIB environment variable unless you set it explicitly in a startup file which is require'd before loading any other module that resides in your local repository. A much nicer approach is to use the lib pragma as we saw before, but in a slightly different way--we use it in the startup file and it affects all the code that will be executed under mod_perl handlers. For example: where startup.pl starts with: Note that you can still use the hard-coded @INC modifications in the scripts themselves, but be aware that scripts modify @INC in BEGIN blocks and mod_perl executes the BEGIN blocks only when it performs script compilation. As a result, @INC will be reset to its original value after the scripts are compiled and the hard-coded settings will be forgotten. The only place you can alter the "original" value is during the server configuration stage either in the startup file or by putting in httpd.conf, but the latter setting will be ignored if you use the PerlTaintcheck setting, and I hope you do use it. The rest of the mod_perl configuration and use is just the same as if you were installing mod_perl as superuser.{mospagebreak title=Local mod_perl Enabled Apache Installation with CPAN.pm} Assuming that you have configured CPAN.pm to install Perl modules locally as explained earlier in this article, the installation is very simple. Start the CPAN.pm shell, set the arguments to be passed to perl Makefile.PL (modify the example setting to suit your needs), and tell CPAN.pm to do the rest for you: When you use CPAN.pm for local installations, after the mod_perl installation is complete you must make sure that the value of makepl_arg is restored to its original value. The simplest way to do this is to quit the interactive shell by typing quit and reenter it. But if you insist here is how to make it work without quitting the shell. You really want to skip this :) If you want to continue working with CPAN *without* quitting the shell, you must:
So if you are still with me, start the shell as usual: First, read the value of the makepl_arg: It will be something like PREFIX=/home/stas if you configured CPAN.pm to install modules locally. Save this value: Second, set a new value, to be used by the mod_perl installation process. (You can add parameters to this line, or remove them, according to your needs.) Third, let CPAN.pm build and install mod_perl for you: Fourth, reset the original value to makepl_arg. We do this by printing the value of the saved variable and assigning it to makepl_arg. Not so neat, but a working solution. You could have written the value on a piece of paper instead of saving it to makepl_arg.save, but you are more likely to make a mistake that way.
blog comments powered by Disqus |