mod_perl logo
perl icon







previous page: Notes on the design and goals of mod_perl-2.0page up: User's guidenext page: mod_perl 2.0 Server Configuration


Installing mod_perl 2.0











Embedding Perl in HTML with Mason

Embedding Perl in HTML with Mason

By Dave Rolsky, Ken Williams
Practical mod_perl

Practical mod_perl

By Stas Bekman, Eric Cholet
The mod_perl Developer's Cookbook

The mod_perl Developer's Cookbook

By Geoffrey Young, Paul Lindner, Randy Kobes


Table of Contents

Description

This chapter provides an in-depth mod_perl 2.0 installation coverage.



TOP

Prerequisites

Before building mod_perl 2.0 you need to have its prerequisites installed. If you don't have them, download and install them first, using the information in the following sections. Otherwise proceed directly to the mod_perl building instructions.

The mod_perl 2.0 prerequisites are:



TOP

Downloading Stable Release Sources

If you are going to install mod_perl on a production site, you want to use the officially released stable components. Since the latest stable versions change all the time you should check for the latest stable version at the listed below URLs:



TOP

Getting Bleeding Edge CVS Sources

If you really know what you are doing you can use the cvs versions of the components. Chances are that you don't want to them on a production site. You have been warned!



TOP

Configuring and Installing Prerequisites

If you don't have the prerequisites installed yet, install them now.



TOP

Installing mod_perl from Binary Packages

As of this writing only the binaries for the Win32 platform are available, kindly prepared and maintained by Randy Kobes. See the documentation on Win32 binaries for details.

Some RPM packages can be found using rpmfind services, e.g.:

http://www.rpmfind.net/linux/rpm2html/search.php?query=mod_perl&submit=Search+... However if you have problems using them, you have to contact those who have created them.



TOP

Installing mod_perl from Source

Building from source is the best option, because it ensures a binary compatibility with Apache and Perl. However it's possible that your distribution provides a solid binary mod_perl 2.0 package.

For Win32 specific details, see the documentation on Win32 installation.



TOP

Downloading the mod_perl Source

First download the mod_perl source.



TOP

Configuring mod_perl

Before you proceed make sure that Apache 2.0 has been built and installed. mod_perl cannot be built before that.

Like any other Perl module, mod_perl is configured via the Makefile.PL file, but requires one or more configuration options:

  % cd modperl-1.99_xx
  % perl Makefile.PL <options>

where options is an optional list of (key,value) pairs.

The following sections give the details about all the available options, but let's mention first the most important ones.

If you want to have mod_perl 1.0 and 2.0 installed under the same perl tree you need to enable MP_INST_APACHE2:

  % perl Makefile.PL MP_INST_APACHE2=1 <other options>

It seems that most users use pre-packaged Apache installation, most of which tend to spread the Apache files across many directories (i.e. not using --enable-layout=Apache, which puts all the files under the same directory). If Apache 2.0 files are spread under different directories, you need to use at least the MP_APXS option, which should be set to a full path to the apxs executable. For example:

  % perl Makefile.PL MP_INST_APACHE2=1 MP_APXS=/path/to/apxs

For example RedHat Linux system installs the httpd binary, the apxs and apr-config scripts (the latter two are needed to build mod_perl) all in different locations, therefore they configure mod_perl 2.0 as:

  % perl Makefile.PL MP_INST_APACHE2=1 MP_APXS=/path/to/apxs \
    MP_APR_CONFIG=/another/path/to/apr-config <other options>

However a correctly built Apache shouldn't require the MP_APR_CONFIG option, since MP_APXS should provide the location of this script.

If however all Apache 2.0 files were installed under the same directory, mod_perl 2.0's build only needs to know the path to that directory, passed via the MP_AP_PREFIX option:

  % perl Makefile.PL MP_INST_APACHE2=1 MP_AP_PREFIX=$HOME/httpd/prefork

These and other options are discussed in the following sections.



TOP

Boolean Build Options

The following options are boolean and can be set with MP_XXX=1 or unset with MP_XXX=0, where XXX is the name of the option.



TOP

MP_PROMPT_DEFAULT

Accept default values for all would-be prompts.



TOP

MP_GENERATE_XS

Generate XS code from parsed source headers in xs/tables/$httpd_version. Default is 1, set to 0 to disable.



TOP

MP_USE_DSO

Build mod_perl as a DSO (mod_perl.so). This is the default. It'll be turned off if MP_USE_STATIC=1 is used.



TOP

MP_USE_STATIC

Build static mod_perl (mod_perl.a). This is the default. It'll be turned off if MP_USE_DSO=1 is used.

MP_USE_DSO and MP_USE_STATIC are both enabled by default. So mod_perl is built once as mod_perl.a and mod_perl.so, but afterwards you can choose which of the two to use.

META: The following is not implemented yet.

  mod_perl and ends up with a src/modules/perl/mod_perl.{so,a} and
  src/modules/perl/ldopts.  to link modperl static with httpd, we just
  need some config.m4 magic to add `ldopts` and mod_perl.a to the build.
  so one could then build httpd like so:
  
  ln -s ~/apache/modperl-2.0/src/modules/perl $PWD/src/modules
  ./configure --with-mpm=prefork --enable-perl=static ...
  
  we not be configuring/building httpd for the user as 1.x attempted.
  
  downside is one will need to have configured httpd first, so that
  headers generated.  so it will probably be more like:
  
  ./configure --with-mpm=prefork ...
  (go build modperl)
  ./config.nice --enable-perl=static && make
  
  we could of course provide a wrapper script todo this, but don't want
  to have this stuff buried and tangled like it is in 1.x


TOP

MP_STATIC_EXTS

Build Apache::*.xs as static extensions.



TOP

MP_USE_GTOP

Link with libgtop and enable libgtop reporting.



TOP

MP_COMPAT_1X

MP_COMPAT_1X=1 or a lack of it enables several mod_perl 1.0 back-compatibility features, which are deprecated in mod_perl 2.0. It's enabled by default, but can be disabled with MP_COMPAT_1X=0 during the build process.

When this option is disabled, the following things will happen:



TOP

MP_DEBUG

Turn on debugging (-g -lperld) and tracing.



TOP

MP_MAINTAINER

Enable maintainer compile mode, which sets MP_DEBUG=1 and adds the following gcc flags:

  -DAP_DEBUG -Wall -Wmissing-prototypes -Wstrict-prototypes \
  -Wmissing-declarations \
  -DAP_DEBUG -DAP_HAVE_DESIGNATED_INITIALIZER

To use this mode Apache must be build with --enable-maintainer-mode.



TOP

MP_TRACE

Enable tracing



TOP

MP_INST_APACHE2

Install all the *.pm modules relative to the Apache2/ directory.



TOP

Non-Boolean Build Options

set the non-boolen options with MP_XXX=value.



TOP

MP_APXS

Path to apxs. For example if you've installed Apache 2.0 under /home/httpd/httpd-2.0 as DSO, the default location would be /home/httpd/httpd-2.0/bin/apxs.



TOP

MP_AP_PREFIX

Apache installation prefix, under which the include/ directory with Apache C header files can be found. For example if you've have installed Apache 2.0 in directory \Apache2 on Win32, you should use:

  MP_AP_PREFIX=\Apache2

If Apache is not installed yet, you can point to the Apache 2.0 source directory, but only after you've built or configured Apache in it. For example:

  MP_AP_PREFIX=/home/stas/apache.org/httpd-2.0

Though in this case make test won't automatically find httpd, therefore you should run t/TEST instead and pass the location of apxs or httpd, e.g.:

  % t/TEST -apxs /home/stas/httpd/prefork/bin/apxs

or

  % t/TEST -httpd /home/stas/httpd/prefork/bin/httpd


TOP

MP_APR_CONFIG

If APR wasn't installed under the same file tree as httpd, you may need to tell the build process where it can find the executable apr-config, which can then be used to figure out where the apr and aprutil include/ and lib/ directories can be found.



TOP

MP_CCOPTS

Add to compiler flags, e.g.:

  MP_CCOPTS=-Werror

(Notice that -Werror will work only with the Perl version 5.7 and higher.)



TOP

MP_OPTIONS_FILE

Read build options from given file. e.g.:

  MP_OPTIONS_FILE=~/.my_mod_perl2_opts


TOP

mod_perl-specific Compiler Options



TOP

-DMP_IOBUFSIZE

Change the default mod_perl's 8K IO buffer size, e.g. to 16K:

  MP_CCOPTS=-DMP_IOBUFSIZE=16384


TOP

mod_perl Options File

Options can also be specified in the file makepl_args.mod_perl2 or .makepl_args.mod_perl2. The file can be placed under $ENV{HOME}, the root of the source package or its parent directory. So if you unpack the mod_perl source into /tmp/mod_perl-2.x/ and your home is /home/foo/, the file will be searched in:

  /tmp/mod_perl-2.x/makepl_args.mod_perl2
  /tmp/makepl_args.mod_perl2
  /home/foo/makepl_args.mod_perl2
  /tmp/mod_perl-2.x/.makepl_args.mod_perl2
  /tmp/.makepl_args.mod_perl2
  /home/foo/.makepl_args.mod_perl2

If the file specified in MP_OPTIONS_FILE is found the makepl_args.mod_perl2 will be ignored.

Options specified on the command line override those from makepl_args.mod_perl2 and those from MP_OPTIONS_FILE.

If your terminal supports colored text you may want to set the environment variable APACHE_TEST_COLOR to 1 to enable the colored tracing which makes it easier to tell the reported errors and warnings, from the rest of the notifications.



TOP

Re-using Configure Options

Since mod_perl remembers what build options were used to build it if first place, you can use this knowledge to rebuild itself using the same options. Simply chdir(1) to the mod_perl source directory and run:

  % cd modperl-2.x.xx
  % perl -MApache::Build -e rebuild


TOP

Compiling mod_perl

Next stage is to build mod_perl:

  % make


TOP

Testing mod_perl

When mod_perl has been built, it's very important to test that everything works on your machine:

  % make test

If something goes wrong with the test phase and want to figure out how to run individual tests and pass various options to the test suite, see the corresponding sections of the bug reporting guidelines or the Apache::Test Framework tutorial.



TOP

Installing mod_perl

Once the test suite has passed, it's a time to install mod_perl.

  % make install

If you install mod_perl system wide, you probably need to become root prior to doing the installation:

  % su
  # make install


TOP

If Something Goes Wrong

If something goes wrong during the installation, try to repeat the installation process from scratch, while verifying all the steps with this document.

If the problem persists report the problem.



TOP

Maintainers

Maintainer is the person(s) you should contact with updates, corrections and patches.



TOP

Authors

Only the major authors are listed above. For contributors see the Changes file.







TOP
previous page: Notes on the design and goals of mod_perl-2.0page up: User's guidenext page: mod_perl 2.0 Server Configuration