mod_perl - Perl module for the Apache HTTP server ChangeLog

HOWTO


# mod_perl
# ========
# As done here, mod_perl is installed as a dynamic module (DSO) for an
# already-installed Apache HTTP server.

# As I type this, mod_perl 2.x is for Apache 2.0, 2.2 and 2.4
#
# The latest full release is at the top, the 'httpd24' development branch is
# toward the bottom.  I have not used the development one recently, probably
# not since 1.99* was the latest tarball available.

# These and more documentation is available on the mod_perl web site:
# Getting Your Feet Wet with mod_perl
# A Reference to mod_perl 1.0 to mod_perl 2.0 Migration
# Installing mod_perl 2.0


# mod_perl 2.0.13
# ===============
# Prerequisites (as it is built below):
# Apache 2.0.47 - 2.4.57 (according to the README)
# APR
# Perl (see README)

# mod_perl 2.0.13 announcement
# Download mirrors

# Get the source tarball
cd
test -f installed/apache2/mod_perl-2.0.13.tar.gz &&
mv installed/apache2/mod_perl-2.0.13.tar.gz .
test ! -f mod_perl-2.0.13.tar.gz &&
wget https://dlcdn.apache.org/perl/mod_perl-2.0.13.tar.gz

# Verify tarball w/ sha1sum:
echo "453c789743487e2d1167d005f21ef9780f36488db8830103e4ea0a0656f\
685bf5ec423cd1baa68ee30efc75d9e2b845c9656458203b9f48de81a315a91d5\
87c9  mod_perl-2.0.13.tar.gz" | sha512sum -c

# Verify tarball w/ gpg:
wget -nc https://dlcdn.apache.org/perl/KEYS -O - | gpg --import -
( gpg --list-keys 40E92ECE > /dev/null 2>&1 || gpg --recv-keys 40E92ECE ) &&
wget -nc https://dlcdn.apache.org/perl/mod_perl-2.0.13.tar.gz.asc &&
  gpg --verify mod_perl-2.0.13.tar.gz.asc && rm mod_perl-2.0.13.tar.gz.asc

# Extract the source
mkdir -p 0700 ~/src/apache2
cd ~/src/apache2
find -maxdepth 1 -type d -name "mod_perl-[12].*" -exec rm -r {} \;
tar xzvf ~/mod_perl-2.0.13.tar.gz
cd mod_perl-2.0.13
test $UID = 0 && chown -R root:root .

# If you're upgrading mod_perl from a version older than 1.999_22, read
# this before continuing below:
# http://perl.apache.org/docs/2.0/rename.html
#
# The key bit of information is that you need to zap at least part of the
# old version to be able to install the new one.  Specifically, you may
# need to run something like this:
# find /usr/lib*/perl5 -type f -name 'Apache2*' -exec rm -r {} \;

# Read 'perldoc ./Changes' if this is an upgrade
# Read ./README and ./INSTALL either way

# Configure the build
#
# If you are doing this for a Slackware-package httpd, use something
# like this:
# perl Makefile.PL MP_APXS=/usr/bin/apxs MP_APR_CONFIG=/usr/bin/apr-1-config
#
# or if your Apache is source-based and installed in the default location:
perl Makefile.PL MP_APXS=/usr/local/apache2/bin/apxs \
MP_APR_CONFIG=/usr/bin/apr-1-config

# Build it
make

# Test it
#
# You may want/need to skip this if you use any security software that
# would not allow it to bind to ports.  LIDS, AppArmor, SELinux, etc.
#
# 'make test' may also fail if, for example, you are upgrading an earlier
# version that had been built with PHP, but you have not installed PHP yet.
# With that example, to get it to work, temporarily comment out the
# LoadModule line in httpd.conf that loads libphp5.so
#
make test

# Become root to install mod_perl
su

# Man pages will be installed under /usr/local/share/man, so either find out
# how to get it to put them in /usr/local/man (INSTALLMAN1DIR, etc.), or
# create a symlink

# Install the new version
make install
find /usr/local/apache2 -user $(logname) -exec chown root:root {} \;

# Make sure your non-root user can remove the source later
chown -R $(logname) .
chmod -R u+w .

# Become yourself again
exit

# Save the tarball for later
cd
test ! -d installed/apache2 && mkdir -p -m 0700 installed/apache2
rm -f installed/apache2/mod_perl-*.tar.* installed/apache2/mod_perl.README
mv mod_perl-2.0.13.tar.gz installed/apache2/

# Skip down to the appropriate CONFIGURATION section below


# mod_perl Subversion
# ===================
# There are lots of mailing list posts referring to getting mod_perl to
# work with Apache HTTP 2.4.x, but I was not able to find one perfect patch
# for 2.0.8  Several for older versions, some for one issue, but not others,
# etc.  Here are some links:
# http://www.gossamer-threads.com/lists/modperl/dev/104221
# http://people.apache.org/~sf/mod_perl/
# http://jkaluza.fedorapeople.org/mod_perl/
#
# So, here I use the 'httpd24' development branch from Subversion:
# http://svn.apache.org/viewvc/perl/modperl/branches/httpd24/

# Prerequisites (as it is built below):
# Subversion
# Apache HTTP 2.0.47 - 2.2.22 (but it should be fine with 2.4.x too)
# APR
# Perl >= 5.6.1 or 5.8.0 or 5.8.2 (see README)

# Create a place to put it, remove old source directories
mkdir -p 0700 ~/src/apache2
cd ~/src/apache2
find -maxdepth 1 -type d -name "mod_perl-*" -a \! -name mod_perl-httpd24 \
-exec rm -r {} \;

# Update or checkout from Subversion repository
test -f ./mod_perl-httpd24 && ( cd mod_perl-httpd24 && svn up )
test ! -f ./mod_perl-httpd24 &&
svn co https://svn.apache.org/repos/asf/perl/modperl/branches/httpd24\
mod_perl-httpd24

# cd to the source directory, clean it up if it's been used before
cd mod_perl-httpd24
test $UID = 0 && chown -R root:root .
test -f ./Makefile && make distclean

# Read 'perldoc ./Changes' if this is an upgrade
# Read ./README and ./INSTALL either way

# Configure the build
#
# If you are doing this for a Slackware-package httpd, use something
# like this:
# perl Makefile.PL MP_APXS=/usr/bin/apxs MP_APR_CONFIG=/usr/bin/apr-1-config
#
# or if your Apache is source-based and installed in the default location:
perl Makefile.PL MP_APXS=/usr/local/apache2/bin/apxs \
MP_APR_CONFIG=/usr/bin/apr-1-config

# Build it
make

# Test it
#
# You may want/need to skip 'make test' if you use any security software
# that would not allow it to bind to ports.  LIDS, AppArmor, SELinux, etc.
#
# Install all of the Perl modules that 'make test' will look for (optional):
su -c "perl -MCPAN -e shell"
o conf prerequisites_policy follow
o conf make_install_arg UNINST=1
install Bundle::CPAN
install Bundle::LWP
exit
#
# 'make test' may also fail if, for example, you are upgrading an earlier
# version of Apache HTTP that had been built with PHP, but you have not
# installed PHP yet.  With that example, to get it to work, comment out this
# line in httpd.conf:
# LoadModule php5_module        modules/libphp5.so
#
# A little ironic, 'make test' appeared to... block... for me at
# t/protocol/echo_nonblock.t
#
make test

# Become root to install it
su

# Install the new version
make install

# Make sure your non-root user can remove the source later
chown -R $(logname) .
chmod -R u+w .

# Become yourself again
exit

# Make note that mod_perl from Subversion is under src/apache2/mod_perl...
cd
rm -f installed/apache2/mod_perl-*.tar.*
mkdir -p -m 0700 installed/apache2
echo "mod_perl is under src/apache2/mod_perl-httpd24" >\
installed/apache2/mod_perl-httpd24.README

# Skip down to the appropriate CONFIGURATION section below


## -=-=-=-=-=-=-
##
## CONFIGURATION - Slackware package based Apache

# Become root if you are not already
# Use a login shell to make sure that newly created files are owned by
# root and not your non-root user
su -

# If the location of apachectl is in your $PATH, you will not need to
# specify the full path below.  It is usually in /usr/sbin

# Create a new directory to put your mod_perl scripts in:
test ! -d /usr/local/apache2 &&
( mkdir -p -m 0750 /var/www/perl
   chown root:apache /var/www/perl )

# Create a httpd-perl.conf file to be included
# If you already have a LoadModule line for it in httpd.conf, remove
# or comment-out the one in httpd-perl.conf
test ! -f /etc/httpd/extra/httpd-perl.conf &&
cat << EOF > /etc/httpd/extra/httpd-perl.conf
LoadModule perl_module modules/mod_perl.so


    Alias /perl/ /var/www/perl/

    
        #SetHandler perl-script
        SetHandler modperl
        PerlResponseHandler ModPerl::Registry
        PerlOptions +ParseHeaders
        Options +ExecCGI
        AllowOverride AuthConfig
        #Allow from all
        Require all granted
    


EOF
chown root:apache /etc/httpd/extra/httpd-perl.conf
chmod 640 /etc/httpd/extra/httpd-perl.conf

# Open up /etc/httpd/httpd.conf in a text editor,
# Add this line at the bottom of the other LoadModule lines
# (without the leading #, which would make it a comment)
#Include /etc/httpd/extra/httpd-perl.conf

# Make sure there is a line in /etc/httpd/httpd.conf that
# includes-in the httpd-perl.conf file
#
#Include /etc/httpd/extra/httpd-perl.conf
egrep -q "^Include[[:space:]]+/etc/httpd/extra/httpd-perl.conf$" \
/etc/httpd/httpd.conf ||
( echo >> /etc/httpd/httpd.conf
   echo "# mod_perl" >> /etc/httpd/httpd.conf
   echo "Include /etc/httpd/extra/httpd-perl.conf" >> /etc/httpd/httpd.conf )

# Make sure all is well with your configuration:
apachectl configtest

# Now restart apache with mod_perl enabled.  If your httpd.conf is set to
# load things that you haven't installed yet (ie. PHP), don't start it
# until they are (or comment out those parts).
apachectl stop
apachectl start

## If you have it enabled, you can run these to get server status info:
# apachectl status
# apachectl full-status
# lynx http://localhost/server-info
## If you do not have it enabled, see /etc/httpd/extra/httpd-info.conf
## Just keep in mind that you probably don't want anyone on the outside
## to be able to look at those details.

# Make sure the server is running everything it should be, either look at
# /var/log/httpd/error_log or run the command below.  It should output
# something like this:
# Server: Apache/2.4.* (Unix) OpenSSL/*.*.* PHP/*.*.* mod_perl/2.0.13
# Perl/v5.x.x
# (if you installed from Subversion, it would say mod_perl/2.0.x-dev)
lynx -dump -width=110 -head http://localhost/ | egrep "^Server:"

# If it did not start, or if it started and it died, look through the
# error_log:
less /var/log/httpd/error_log


## -=-=-=-=-=-
##
## CONFIGURATION - Source

# Become root if you are not already
# Use a login shell to avoid some su's that may leave files owned by your
# non-root user
su -

# If /usr/local/apache2/bin is in your $PATH, you will not need to specify
# the full path to 'apachectl' below.  If it is not, then use the full path
# of /usr/local/apache2/bin/apachectl instead.
(echo $PATH | grep -q "/usr/local/apache2/bin") ||
PATH=$PATH:/usr/local/apache2/bin

# Create a new directory to put your mod_perl scripts in:
test -d /usr/local/apache2 &&
( mkdir -p -m 0750 /usr/local/apache2/perl
   chown root:daemon /usr/local/apache2/perl )

# Create an Apache 2.4.x style httpd-perl.conf file to include
# If you already have a LoadModule line for it in httpd.conf, remove
# or comment-out the one in httpd-perl.conf
cat << EOF > /usr/local/apache2/conf/extra/httpd-perl.conf
LoadModule perl_module modules/mod_perl.so


    Alias /perl/ /usr/local/apache2/perl/

    
        #SetHandler perl-script
        SetHandler modperl
        PerlResponseHandler ModPerl::Registry
        PerlOptions +ParseHeaders
        Options +ExecCGI
        AllowOverride AuthConfig
        #Allow from all
        Require all granted
    


EOF
chown root:daemon /usr/local/apache2/conf/extra/httpd-perl.conf
chmod 640 /usr/local/apache2/conf/extra/httpd-perl.conf

# Make sure there is a line in /usr/local/apache2/conf/httpd.conf that
# includes-in the httpd-perl.conf file
#
#Include /usr/local/apache2/conf/extra/httpd-perl.conf
egrep -q "^Include[[:space:]]+conf/extra/httpd-perl.conf$" \
/usr/local/apache2/conf/httpd.conf ||
( echo >> /usr/local/apache2/conf/httpd.conf
   echo "# mod_perl" >> /usr/local/apache2/conf/httpd.conf
   echo "Include conf/extra/httpd-perl.conf" >> \
    /usr/local/apache2/conf/httpd.conf )

# Make sure all is well with your configuration:
apachectl configtest

# Now restart apache with mod_perl enabled.  If your httpd.conf is set to
# load things that you haven't installed yet (ie. PHP), don't start it
# until they are (or comment out those parts).
apachectl stop
apachectl start

## If you have it enabled, you can run these to get server status info:
# apachectl status
# apachectl full-status
# lynx http://localhost/server-info
## If you do not have it enabled, see /etc/httpd/extra/httpd-info.conf
## Just keep in mind that you probably don't want anyone on the outside
## to be able to look at those details.

# Make sure the server is running everything it should be, either look at
# /usr/local/apache2/logs/error_log or run the command below.  It should
# output something like this:
# Server: Apache/2.4.* (Unix) OpenSSL/*.*.* PHP/*.*.* mod_perl/2.0.13
# Perl/v5.x.x
lynx -dump -width=110 -head http://localhost/ | egrep "^Server:"

# If it did not start, or if it started and it died, look through the
# error_log:
less /usr/local/apache2/logs/error_log


## -=-=-=-=-=-
##
## Uninstall mod_perl

# All installed files should be listed in a .packlist file somewhere
# similar this this path:
# /usr/local/lib*/perl5/auto/mod_perl2/.packlist
#
# If you ever want to uninstall mod_perl, this should do it:
cd
su
test -d src/apache2/mod_perl-* &&
( cd src/apache2/mod_perl-* ; make uninstall )
rm -f /etc/httpd/extra/httpd-perl.conf \
/usr/local/apache2/conf/extra/httpd-perl.conf
exit
find ~/src/apache2 -maxdepth 1 -type d -name "mod_perl-*" -exec rm -r {} \;
rm -f ~/installed/apache2/mod_perl-*.tar.*

List of HOWTOs

Web page itself last updated: 2023-12-20 8:06pm (EST -0500)
HOWTO last updated: 2023-12-07 11:43pm
Copyright © 2001-2024 Jason Englander. All Rights reserved.
[HTML5]