Stories
Slash Boxes
Comments

Slash Open Source Project

Slashcode Log In

Log In

[ Create a new account ]

MoonFacedAssassin (3773)

MoonFacedAssassin
  (email not shown publicly)
Friday January 03, 03

PHP with Apache and Mod Perl

02:50 PM
Apache
For others and so I have a log myself here's how I got PHP to work with mod_perl and apache:

Here are the versions of software I used:

Apache 1.3.27
Mod Perl 1.27
PHP 4.3.0

The following needs to be done first so PHP's ./configure doesn't complain:
In Apache directory:

./configure --prefix=<path to apache install> --activate-module=src/modules/php4/libphp4.a --activate-module=src/modules/perl/libperl.a

In PHP directory:

./configure --with-mysql=<path to mysql install> --with-apache=<path to apache root source> --enable-track-vars
./make
./make install

In mod_perl directory:
Edit the Makefile.PL file and look for the line (was line number 1029 for me) that has the following:

$cmd .= "./configure " . "--activate-module=src/modules/perl/libperl.a";

Add this to the end of the quotes (but before the semi-colon):

. " --activate-module=src/modules/php4/libphp4.a"

Save this file and now run this:

perl Makefile.PL APACHE_SRC=<path to apache root source> DO_HTTPD=1 USE_APACI=1 PERL_MARK_WHERE=1 EVERYTHING=1 APACHE_PREFIX=<path to apache install>

The output of the perl command should be something like this:

Will configure via APACI
cp apaci/Makefile.libdir ../apache_1.3.27/src/modules/perl/Makefile.libdir
cp apaci/Makefile.tmpl ../apache_1.3.27/src/modules/perl/Makefile.tmpl
cp apaci/README ../apache_1.3.27/src/modules/perl/README
cp apaci/configure ../apache_1.3.27/src/modules/perl/configure
cp apaci/libperl.module ../apache_1.3.27/src/modules/perl/libperl.module
cp apaci/mod_perl.config.sh ../apache_1.3.27/src/modules/perl/mod_perl.config. sh
cp apaci/load_modules.pl ../apache_1.3.27/src/modules/perl/load_modules.pl
cp apaci/find_source ../apache_1.3.27/src/modules/perl/find_source
cp apaci/apxs_cflags ../apache_1.3.27/src/modules/perl/apxs_cflags
cp apaci/perl_config ../apache_1.3.27/src/modules/perl/perl_config
cp apaci/mod_perl.exp ../apache_1.3.27/src/modules/perl/mod_perl.exp
PerlDispatchHandler.........enabled
PerlChildInitHandler........enabled
PerlChildExitHandler........enabled
PerlPostReadRequestHandler..enabled
PerlTransHandler............enabled
PerlHeaderParserHandler.....enabled
PerlAccessHandler...........enabled
PerlAuthenHandler...........enabled
PerlAuthzHandler............enabled
PerlTypeHandler.............enabled
PerlFixupHandler............enabled
PerlHandler.................enabled
PerlLogHandler..............enabled
PerlInitHandler.............enabled
PerlCleanupHandler..........enabled
PerlRestartHandler..........enabled
PerlStackedHandlers.........enabled
PerlMethodHandlers..........enabled
PerlDirectiveHandlers.......enabled
PerlTableApi................enabled
PerlLogApi..................enabled
PerlUriApi..................enabled
PerlUtilApi.................enabled
PerlFileApi.................enabled
PerlConnectionApi...........enabled
PerlServerApi...............enabled
PerlSections................enabled
PerlSSI.....................enabled
PERL_MARK_WHERE.............enabled (experimental)
Will run tests as User: 'nobody' Group: 'root'
(cd ../apache_1.3.27 && CC="gcc" CFLAGS=" -DPERL_MARK_WHERE=1 -D_REENTRANT -fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdb
m" ./configure --activate-module=src/modules/perl/libperl.a --activate-module=src/modules/php4/libphp4.a --disable-rule=EXPAT --prefix=/home/justin/tempapach
e)
Configuring for Apache, Version 1.3.27
+ using installation path layout: Apache (config.layout)
+ activated perl module (modules/perl/libperl.a)
+ activated php4 module (modules/php4/libphp4.a)
Creating Makefile
Creating Configuration.apaci in src
+ id: mod_perl/1.27
+ id: Perl/v5.8.0 (linux) [/usr/bin/perl]
Creating Makefile in src
+ configured for Linux platform
+ setting C pre-processor to gcc -E
+ checking for system header files
+ adding selected modules
o perl_module uses ConfigStart/End
+ mod_perl build type: OBJ
+ setting up mod_perl build environment
+ adjusting Apache build environment
+ enabling Perl support for SSI (mod_include)
o php4_module uses ConfigStart/End
+ checking sizeof various data types
+ doing sanity check on compiler and options
Creating Makefile in src/support
Creating Makefile in src/os/unix
Creating Makefile in src/ap
Creating Makefile in src/main
Creating Makefile in src/modules/standard
Creating Makefile in src/modules/perl
Creating Makefile in src/modules/php4
Checking CGI.pm VERSION..........ok
Checking for LWP::UserAgent......ok
Checking for HTML::HeadParser....ok
Writing Makefile for Apache
Writing Makefile for Apache::Connection
Writing Makefile for Apache::Constants
Writing Makefile for Apache::File
Writing Makefile for Apache::Leak
Writing Makefile for Apache::Log
Writing Makefile for Apache::ModuleConfig
Writing Makefile for Apache::PerlRunXS
Writing Makefile for Apache::Server
Writing Makefile for Apache::Symbol
Writing Makefile for Apache::Table
Writing Makefile for Apache::URI
Writing Makefile for Apache::Util
Writing Makefile for mod_perl

Take note of these two lines:

+ activated perl module (modules/perl/libperl.a)
+ activated php4 module (modules/php4/libphp4.a)

If those two lines are present then both php and mod_perl will be staticly linked in apache (i.e. no DSO involved)

Now in mod_perl directory:

./make
./make install

The ./make should compile mod_perl and php into apache (basically by running apache's Makefiles) and then ./make install will install apache into the APACHE_PREFIX specified earlier.

Now edit httpd.conf and add or uncomment this line:

AddType application/x-httpd-php .php .php3 .phtml

Now install Slash (and whatever perl modules are necessary). Don't forget to copy PHP's php.ini file to /usr/local/lib and edit it as necessary.