|
Recipe for building php-2.0.1 with Apache-1.3.3 and PHP 3.0.5 The first thing you want to think about is what you want to do about the regex libray. You must use the same library on php-2.0.1, php-3.0.5, and Apache. Here is what Ramsus had to say in the php-dev list: There is an Apache dependancy here. When you first configure Apache it creates an ap_config.h file which PHP includes. This ap_config.h file will include the Apache regex library by default. So, in order to use your system's regex library you will have to first configure Apache to use that library. ie. build Apache once without PHP and make sure you build it such that it uses your system's regex lib. Then, once that works, configure and build PHP with your system regex library and then rebuild Apache with PHP support.I used the exact regex library that came with php-3.0.5 since using the Linux system library caused errors on compiling. To do this you must replace the directory php-2.0.1/src/regex/ with the php-3.0.5/src/regex directory AFTER you've compiled PHP3. Next create the header files in the apache directory that PHP3 looks for. Start in the Apache directory and run ./configure. I used --exec-prefix=/usr because that's where the RedHat rpm installed the apache executables: cd apache_1.3.3 ./configure --prefix=/ --exec-prefix=/usrThis is done so that a couple of auto-generated header files will be there when you configure PHP3. (see note above about regex) Next, follow the standard installation directions for PHP3. Something like: cd php-3.0.5 ./configure --with-apache=../apache_1.3.3 make make installNext ensure that PHP2 and PHP3 are using the same regex. cd php-2.0.1/src mv regex regex.old cp -r ../../php-3.0.5/regex . That part may not be necessary, - here is what the Guru of PHP himself had to say about it on the php-dev list - but it didn't hurt and I like to be extra paranoid when compiling. Now the tricky part. PHP2 was written long before Apache-1.3.3 was released, so it isn't quite a smooth as it could be. There is a bug in mod_php.module.in. The trailing " is missing. Edit this file and add that. Then run the ./install program. Again, think about the regex you want to use. I set it to use the included regex library (the one replaced by php-3.0.5). During the install it asks you for the Apache include directory. It will be something like <path>/apache_1.3.3/src/include. After the install program has finished you will need to edit 3 files. First, edit src/php.h and down around line 95 you will find a line that says: #include "httpd.h"Just before this line, add a line that says: #include "ap_compat.h"Do the same thing in mod_php.c. Just before the #include "httpd.h" line add #include "ap_compat.h" The third file you need to edit is src/Makefile. On the CPPFLAGS line around line 47 you will see a line which among other things has a -I followed by the Apache include directory you specified earlier. Add another -I entry with the same path but instead of ending in src/include it needs to end in src/os/unix. For example, on my system this line looks like this after fixing it: CPPFLAGS = -I./regex -I. -I/usr/local/include/mysql -DHAVE_LIBMYSQL=1 \ -I/usr/local/src/apache_1.3.3/src/include -I/usr/local/src/apache_1.3.3/src/os/unix \ -DFILE_UPLOAD -DAPACHE=1 -DAPACHE_NEWAPI=1 -DPHPSENDMAIL=1 -DSENDMAIL=\""/var/qmail/bin/sendmail -t"\" \ $(DEBUG)Here's a gotcha: In RH Linux 5.0, if you decide to use the regex included with php3, then make sure you do NOT have -I/usr/include on the line INC_FLAGS becuase you will get errors in compiling Now you can run make. It will copy a bunch of files to the Apache src/include directory when it is finished. That is the wrong place for these files. You should copy libphp.a and mod_php.* to the Apache src/modules/extra directory. Back to the apache_1.3.3 directory. Now (in my opinion) the ./configure command does not work well for anythng that is not the standard. So go ahead and run the configure script again. E.G.: ./configure --prefix=/ --exec-prefix=/usr --enable-module=rewrite --enable-module=speling --logfiledir=/var/log/httpd --activate-module=src/modules/php3/libphp3.a --activate-module=src/modules/extra/mod_php.o --enable-rule=WANTHSREGEX=yesBut now we have to edit the Makefile in src.
i.e. vi src/Makefile Now you can run make and you should end up with an httpd binary that includes both the PHP2 and the PHP3 module. You can then set your AddType lines in src.conf to poing .phtml files at PHP2 and .php3 files at PHP3, for example. AddType application/x-httpd-php .phtml AddType application/x-httpd-php3 .php3 |