Now that we know 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. We'll talk about it 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:
panic% ls /home/stas/src /home/stas/src/apache_1.3.xx /home/stas/src/mod_perl-1.xx
where x.xx are replaced by the real 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:
panic% perl Makefile.PL \ PREFIX=/home/stas \ APACHE_PREFIX=/home/stas/apache \ APACHE_SRC=../apache_1.3.xx/src \ DO_HTTPD=1 \ USE_APACI=1 \ EVERYTHING=1 panic% make && make test && make install panic% cd ../apache_1.3.xx panic% make install
If you need some parameters to be passed to the ./configure script, as we saw in the previous section, use APACI_ARGS. For example:
APACI_ARGS='--sbindir=/home/stas/apache/sbin \ --sysconfdir=/home/stas/apache/conf \ --logfiledir=/home/stas/apache/logs'
Note that the above multiline splitting will work only with Bourne-style shells. C-style shell 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 that is required 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:
use lib qw(/home/stas/lib/perl5/5.6.1/ /home/stas/lib/perl5/site_perl/5.6.1 /home/stas/lib/perl5/site_perl );
Note that you can still use the hardcoded @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 hardcoded settings will be forgotten.
The only time you can alter the "original" value is during the server configuration stage, either in the startup file or by putting the following line in httpd.conf:
PerlSetEnv Perl5LIB \ /home/stas/lib/perl5/5.6.1/:/home/stas/lib/perl5/site_perl/5.6.1
But the latter setting will be ignored if you use the PerlTaintchecksetting, and we hope you do use it. See the perlrun manpage for more information.
The rest of the mod_perl configuration can be done just as if you were installing mod_perl as root.
Another important thing to keep in mind is the consumption of system resources. mod_perl is memory-hungry. If you run a lot of mod_perl processes on a public, multiuser machine, most likely the system administrator of this machine will ask you to use fewer resources and may even shut down your mod_perl server and ask you to find another home for it. You have a few options:
Reduce resource usage as explained in Chapter 21.
Ask your ISP's system administrator whether she can set up a dedicated machine for you, so that you will be able to install as much memory as you need. If you get a dedicated machine, chances are that you will want to have root access, so you may be able to manage the administration yourself. You should also make sure the system administrator is responsible for a reliable electricity supply and a reliable network link. The system administrator should also make sure that the important security patches get applied and the machine is configured to be secure (not to mention having the machine physically protected, so no one will turn off the power or break it).
The best solution might be to look for another ISP with lots of resources or one that supports mod_perl. You can find a list of these ISPs at http://perl.apache.org/.