Installation of mod_perl-enabled Apache Without Superuser Privileges Page 6

執筆者
Stas Bekman
Stas Bekman
Published: Jul 20, 2010
Updated: Nov 10, 2020
2 minute read
ServerWatch のコンテンツおよび製品のおすすめは、編集上の独立性を保っています。パートナーへのリンクをクリックすると、当社が報酬を得る場合があります。 詳細を見る



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:

  % 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 .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/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
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:

  PerlRequire /home/stas/apache/perl/startup.pl

where startup.pl starts with:

  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 @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 :

  PerlSetEnv Perl5LIB   /home/stas/lib/perl5/5.00503/:/home/stas/lib/perl5/site_perl/5.005

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.

Local mod_perl Enabled Apache Installation with CPAN.pm

Advertisement

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:

  % 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 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.

Stas Bekman

Stas Bekman is a ServerWatch contributor.

ServerWatch Logo

ServerWatch is a top resource on servers. Explore the latest news, reviews and guides for server administrators now.

TechnologyAdvice が所有・運営しています。 © 2026 TechnologyAdvice. 無断転載を禁じます

広告主に関する開示:このサイトに掲載されている製品の一部は、TechnologyAdvice が報酬を受け取っている企業のものです。この報酬は、製品がこのサイトのどこにどのように表示されるか(表示される順序など)に影響する場合があります。TechnologyAdvice は、市場で入手可能なすべての企業やすべての種類の製品を掲載しているわけではありません。