Installing Apache for LAMP

From Dev411: The Code Wiki

These notes are for a LAMP installation using Apache 2.x and mod_perl 2.x

The software

Installation

Installing Apache (2.x)

 ./configure --prefix=/usr/local/apache2 --with-mpm=prefork --enable-so
 make
 make install

If you wish to add SSL, you can add the following options:

 --with-ssl=/usr/local/ssl --enable-ssl=shared 
 --enable-mods-shared=all

Installing Perl (5.8.7)

 sh Configure -Dcc=gcc -Uusethreads -Dprefix=/usr -des
 make
 make test
 make install

Installing mod_perl and Apache::DBI (2.x)

 perl Makefile.PL MP_APXS=/usr/local/apache2/bin/apxs
 make
 make test
 make install
 perl -MCPAN -e 'install Apache::DBI'

Installing Apache HTTP Request Library (2.x)

To use --enable-perl-glue you may need to first install the Perl module ExtUtils::XSBuilder::ParseSource:

 perl -MCPAN -e 'install ExtUtils::XSBuilder::ParseSource'
 ./configure --with-apache2-apxs=/path/to/apache2/bin/apxs --enable-perl-glue
 make
 make test
 make install
 make clean

Installing PHP (5.x)

 ./configure --with-apxs2=/path/to/apache2/bin/apxs --with-mysql --with-zlib
 make
 make test
 make install
 make clean

If you intend to use Perl's PHP::Interpreter, use:

 ./configure --with-mysql --with-zlib --enable-embed --enable-maintainer-zts

There are some problems with using PHP::Interpreter with APXS as posted on codecomments.com (http://www.codecomments.com/PERL_PHP_module/message688233-1.html)

Configure Apache

The following are useful edits to the Apache 2.x httpd.conf file

To enable mod_perl load the following modules. PHP edits the httpd.conf file for you so it should already be there.

 LoadModule apreq_module  modules/mod_apreq2.so
 LoadModule perl_module   modules/mod_perl.so

To use Apache::DBI include the following line:

 PerlModule Apache::DBI

To use a mod_perl startup.pl file, include the following line:

 PerlRequire /path/to/apache2/bin/startup.pl

Use .htaccess files, comment out the following line where appropriate:

 #AllowOverride None

To stop Apache from filling the error_log with favicon requests

 Redirect 404 /favicon.ico