Your Daily Source for Apache News and Information |
Breaking News | Preferences | Contribute | Triggers | Link Us | Search | About |
|
By As you have seen from my previous articles, mod_perl-enabled Apache consists of two main components: Perl modules and Apache itself. While installing Apache without root privileges is a very easy task, one should know how to install Perl modules in a non-systemwide location. In this article I'll show different ways to tackle this task. In the examples used in this article I'll use Installing Perl Modules into a Directory of ChoiceSince without superuser permissions you aren't allowed to install modules into system directories like First you have to decide where to install the modules. The simplest approach is to simulate the portion of the /home/stas/bin /home/stas/lib We don't have to create them, since that will be done automatically when the first module is installed. 99 percent of the files will go into the Let's install the Now do a standard % perl Makefile.PL PREFIX=/home/stas
% perl Makefile.PL PREFIX=/home/stas \ INSTALLPRIVLIB=/home/stas/lib/perl5 \ INSTALLSCRIPT=/home/stas/bin \ INSTALLSITELIB=/home/stas/lib/perl5/site_perl \ INSTALLBIN=/home/stas/bin \ INSTALLMAN1DIR=/home/stas/lib/perl5/man \ INSTALLMAN3DIR=/home/stas/lib/perl5/man3 The rest is as usual: % make % make test % make install
Installing /home/stas/lib/perl5/CGI/Cookie.pm Installing /home/stas/lib/perl5/CGI.pm Installing /home/stas/lib/perl5/man3/CGI.3 Installing /home/stas/lib/perl5/man3/CGI::Cookie.3 Writing /home/stas/lib/perl5/auto/CGI/.packlist Appending installation info to /home/stas/lib/perl5/perllocal.pod If you have to use the explicit target parameters, instead of a single PREFIX=/home/stas \ INSTALLPRIVLIB=/home/stas/lib/perl5 \ INSTALLSCRIPT=/home/stas/bin \ INSTALLSITELIB=/home/stas/lib/perl5/site_perl \ INSTALLBIN=/home/stas/bin \ INSTALLMAN1DIR=/home/stas/lib/perl5/man \ INSTALLMAN3DIR=/home/stas/lib/perl5/man3 From now on, any time you want to install perl modules locally you simply execute: % perl Makefile.PL `cat ~/.perl_dirs` % make % make test % make install Using this method you can easily maintain several Perl module repositories. For example, you could have one for production Perl and another for development: % perl Makefile.PL `cat ~/.perl_dirs.production` or: % perl Makefile.PL `cat ~/.perl_dirs.develop` Making Your Scripts Find the Locally Installed ModulesPerl modules are generally placed in four main directories. To find these directories, execute: % perl -V The output contains important information about your Perl installation. At the end you will see: Characteristics of this binary (from libperl): Built under linux Compiled at Apr 6 1999 23:34:07 @INC: /usr/lib/perl5/5.00503/i386-linux /usr/lib/perl5/5.00503 /usr/lib/perl5/site_perl/5.005/i386-linux /usr/lib/perl5/site_perl/5.005 . It shows us the content of the Perl special variable Notice that Perl looks for modules in the Of course this example is from version 5.00503 of Perl installed on my x86 architecture PC running Linux. That's why you see i386-linux and 5.00503. If your system runs a different version of Perl, operating system, processor or chipset architecture, then some of the directories will have different names. I also have a perl-5.6.0 installed under % /usr/local/bin/perl5.6.0 -V I see: @INC: /usr/local/lib/perl5/5.6.0/i586-linux /usr/local/lib/perl5/5.6.0 /usr/local/lib/site_perl/5.6.0/i586-linux /usr/local/lib/site_perl Note that it's still Linux, but the newer Perl version uses the version of my Pentium processor (thus the i586 and not i386). This makes use of compiler optimizations for Pentium processors when the binary Perl extensions are created. All the platform specific files, such as compiled C files glued to Perl with Important: As we have installed the Perl modules into non-standard directories, we have to let Perl know where to look for the four directories. There are two ways to accomplish this. You can either set the Assuming that we use perl-5.00503, in our example the directories are: /home/sbekman/lib/perl5/5.00503/i386-linux /home/sbekman/lib/perl5/5.00503 /home/sbekman/lib/perl5/site_perl/5.005/i386-linux /home/sbekman/lib/perl5/site_perl/5.005 As mentioned before, you find the exact directories by executing Modifying use lib qw(/home/stas/lib/perl5/5.00503/ /home/stas/lib/perl5/site_perl/5.005); Another way is to write code to modify BEGIN { unshift @INC, qw(/home/stas/lib/perl5/5.00503 /home/stas/lib/perl5/5.00503/i386-linux /home/stas/lib/perl5/site_perl/5.005 /home/stas/lib/perl5/site_perl/5.005/i386-linux); } Note that with the Also, notice that both approaches prepend the directories to be searched to Both approaches modify the value of Now, let's assume the following scenario. I have installed the There is no way for Perl to know that we have some locally installed modules. All it does is search the directories listed in setenv PERL5LIB /home/stas/lib/perl5/5.00503: /home/stas/lib/perl5/site_perl/5.005 It should be a single line with directories separated by colons ( export PERL5LIB=/home/stas/lib/perl5/5.00503: /home/stas/lib/perl5/site_perl/5.005 Again, make it a single line. If you use bash you can use multi-line commands by terminating split lines with a backslash ( export PERL5LIB=/home/stas/lib/perl5/5.00503:\ /home/stas/lib/perl5/site_perl/5.005 As with When you have done this, verify the value of the newly configured % perl -V Characteristics of this binary (from libperl): Built under linux Compiled at Apr 6 1999 23:34:07 %ENV: PERL5LIB="/home/stas/lib/perl5/5.00503: /home/stas/lib/perl5/site_perl/5.005" @INC: /home/stas/lib/perl5/5.00503/i386-linux /home/stas/lib/perl5/5.00503 /home/stas/lib/perl5/site_perl/5.005/i386-linux /home/stas/lib/perl5/site_perl/5.005 /usr/lib/perl5/5.00503/i386-linux /usr/lib/perl5/5.00503 /usr/lib/perl5/site_perl/5.005/i386-linux /usr/lib/perl5/site_perl/5.005 . When everything works as you want it to, add these commands to your Note that if you have a So the best approach is to have both the The CPAN.pm Shell and Locally Installed ModulesThe When you start the /home/stas/.cpan/CPAN/MyConfig.pm /usr/lib/perl5/5.00503/CPAN/Config.pm If there is no If you've got it already system-wide configured, you should have a % mkdir -p /home/stas/.cpan/CPAN Now copy the system wide configuration file to your local one: % cp /usr/lib/perl5/5.00503/CPAN/Config.pm \ /home/stas/.cpan/CPAN/MyConfig.pm The only thing left is to change the base directory of % perl -pi -e 's|/usr/src|/home/stas|' \ /home/stas/.cpan/CPAN/MyConfig.pm Now you have the local configuration file ready, you have to tell it what special parameters you need to pass when executing the Open the file in your favorite editor and replace line: 'makepl_arg' => q[], with: 'makepl_arg' => q[PREFIX=/home/stas], Now you've finished the configuration. Assuming that you are logged in as the same user you have prepared the local installation for (stas in our example), start it like this: % perl -MCPAN -e shell From now on any module you try to install will be installed locally. If you need to install some system modules, just become the superuser and install them in the same way. When you are logged in as the superuser, the system-wide configuration file will be used instead of your local one. If you have used more than just the perl Makefile.PL PREFIX=/home/stas \ INSTALLPRIVLIB=/home/stas/lib/perl5 \ INSTALLSCRIPT=/home/stas/bin \ INSTALLSITELIB=/home/stas/lib/perl5/site_perl \ INSTALLBIN=/home/stas/bin \ INSTALLMAN1DIR=/home/stas/lib/perl5/man \ INSTALLMAN3DIR=/home/stas/lib/perl5/man3 then replace 'makepl_arg' => q[PREFIX=/home/stas], with all the variables from above, so that the line becomes: 'makepl_arg' => q[PREFIX=/home/stas \ INSTALLPRIVLIB=/home/stas/lib/perl5 \ INSTALLSCRIPT=/home/stas/bin \ INSTALLSITELIB=/home/stas/lib/perl5/site_perl \ INSTALLBIN=/home/stas/bin \ INSTALLMAN1DIR=/home/stas/lib/perl5/man \ INSTALLMAN3DIR=/home/stas/lib/perl5/man3], If you arrange all the above parameters in one line, you can remove the backslashes ( Making a Local Apache InstallationJust like with Perl modules, if you don't have permissions to install files into the system area you have to install them locally under your home directory. It's almost the same as a plain installation, but you have to run the server listening to a port number greater than 1024 since only root processes can listen to lower numbered ports. Another important issue you have to resolve is how to add startup and shutdown scripts to the directories used by the rest of the system services. You will have to ask your system administrator to assist you with this issue. To install Apache locally, all you have to do is to tell ./configure --prefix=/home/stas Apache will use the prefix for the rest of its target directories instead of the default ./configure --prefix=/home/stas --show-layout You might want to put all the Apache files under ./configure --prefix=/home/stas/apache If you want to modify some or all of the names of the automatically created directories: ./configure --prefix=/home/stas/apache \ --sbindir=/home/stas/apache/sbin --sysconfdir=/home/stas/apache/etc --localstatedir=/home/stas/apache/var \ --runtimedir=/home/stas/apache/var/run \ --logfiledir=/home/stas/apache/var/logs \ --proxycachedir=/home/stas/apache/var/proxy That's all! Also remember that you can start the script only under a user and group you belong to. You must set the Manual Local mod_perl Enabled Apache InstallationNow 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 % ls /home/stas/src /home/stas/src/apache_x.x.x /home/stas/src/mod_perl-x.xx where x.xx are the version numbers as usual. You want the Perl modules from the mod_perl package to be installed under % perl Makefile.PL \ PREFIX=/home/stas \ APACHE_PREFIX=/home/stas/apache \ APACHE_SRC=../apache_x.x.x/src \ DO_HTTPD=1 \ USE_APACI=1 \ EVERYTHING=1 % make && make test && make install % cd ../apache_x.x.x % make install If you need some parameters to be passed to the APACI_ARGS='--sbindir=/home/stas/apache/sbin, \ --sysconfdir=/home/stas/apache/etc, \ --localstatedir=/home/stas/apache/var, \ --runtimedir=/home/stas/apache/var/run, \ --logfiledir=/home/stas/apache/var/logs, \ --proxycachedir=/home/stas/apache/var/proxy' Note that the above multiline splitting will work only with Basically the installation is complete. The only remaining problem is the PerlRequire /home/stas/apache/perl/startup.pl where use lib qw(/home/stas/lib/perl5/5.00503/ /home/stas/lib/perl5/site_perl/5.005); Note that you can still use the hard-coded The only place you can alter the "original" value is during the server configuration stage either in the startup file or by putting : PerlSetEnv Perl5LIB \ /home/stas/lib/perl5/5.00503/:/home/stas/lib/perl5/site_perl/5.005 in The rest of the mod_perl configuration and use is just the same as if you were installing mod_perl as superuser. Local mod_perl Enabled Apache Installation with CPAN.pmAssuming that you have configured % perl -MCPAN -eshell cpan> o conf makepl_arg 'DO_HTTPD=1 USE_APACI=1 EVERYTHING=1 \ PREFIX=/home/stas APACHE_PREFIX=/home/stas/apache' cpan> install mod_perl When you use The simplest way to do this is to quit the interactive shell by typing If you want to continue working with
this is quite a cumbersome task as of this writing, but I believe that So if you are still with me, start the shell as usual: % perl -MCPAN -eshell First, read the value of the cpan> o conf makepl_arg PREFIX=/home/stas It will be something like cpan> o conf makepl_arg.save PREFIX=/home/stas 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.) To wit: cpan> o conf makepl_arg 'DO_HTTPD=1 USE_APACI=1 EVERYTHING=1 \ PREFIX=/home/stas APACHE_PREFIX=/home/stas/apache' Third, let cpan> install mod_perl Fourth, reset the original value to cpan> o conf makepl_arg.save PREFIX=/home/stas cpan> o conf makepl_arg PREFIX=/home/stas Not so neat, but a working solution. You could have written the value on a piece of paper instead of saving it to References
About the Authoris an author of the mod_perl Guide and is currently co-athoring a book about mod_perl for O'Reilly and Associates, Inc together with Eric Cholet. He is a member of the Apache Software Foundation. You can find more about his works and joys at his personal web site. |
|
No talkbacks posted. |
About Triggers | Media Kit | Security | Triggers | Login |
All times are recorded in UTC. Linux is a trademark of Linus Torvalds. Powered by Linux 2.4, Apache 1.3, and PHP 4 Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy. |