iTools 7.x: How To Build Custom PHP Modules
This document explains the process of compiling mod_php4 for iTools 7.x (Apache 2.0). iTools customers who wish to use the powerful and flexible PHP4 module, but find that the delivered Tenon PHP module does not include various extentions that they desire, may build a replacement PHP module.
This is the build process Tenon has used with version 4.3.2 of the PHP module. The first step, naturally, is to acquire the source code. This can be downloaded from http://www.php.net. Go to the link called 'Downloads' at the top of the page and download the tar/gz file. All of the following steps must be completed in the Terminal. As a warning, this process will probably cause an enormous amount of frustration for those without a minimal amount of experience compiling Apache modules, or free software in general.
Next, untar the source file (type 'tar zxvf filename.tar.gz' in the terminal) to reveal the source directory, called 'php-4.x.x', where 'x.x' is the minor version number. We will refer to this directory as the 'toplevel' directory for the remainder of this document. After untarring the source tree, we need to configure the source to specify which options we want to compile into our module. Inside the source directory is a script call 'configure'. By executing 'configure' with the '--help' argument, we can get a list of all of the available options to compile our module.
One important option we must take note of is '--with-apxs2'. apxs is a Perl script, bundled with the standard Apache and used to compile dynamically loadable modules that conform to the Apache version currently installed on your computer. The apxs script passes the appropriate options to the compiler during the build process to ensure that the module is built with the same specifications that Apache was built to.
iTools includes an apxs script located in /Library/Tenon/WebServer/Executables. When configuring PHP, we need to specify the '--with-apxs2=/Library/Tenon/WebServer/Executables/apxs' option to the configure script. This will build a PHP module that will conform to the iTools Apache.
There are, of course, a multitude of other options available which we can see when we execute configure with the '--help' argument. The standard Tenon configure options are below:
./configure --prefix=/Library/Tenon/PHP \ --with-openssl=/usr \ --with-config-file-path=/Library/Tenon/PHP/lib \ --with-ldap=/usr --with-xml --enable-shared \ --enable-trans-id --enable-track-vars \ --enable-ftp --with-mysql=/Library/Tenon/MySQL \ --with-pdflib=/Library/Tenon/PHP \ --with-zlib=/usr --with-png-dir=/usr/local \ --with-jpeg-dir=/usr/local \ --with-iconv-dir=/Library/Tenon/PHP \ --with-tiff-dir=/Library/Tenon/PHP \ --with-apxs2=/Library/Tenon/WebServer/Executables/apxs \ --enable-openbase_module \ --with-curl=/Library/Tenon/PHP \ --enable-exif --enable-wddx \ --enable-mbstring --enable-mbregex \ --enable-session --enable-tokenizer \ --enable-mime-magic \ --with-xslt-sablot=/Library/Tenon/PHP \ --enable-xsl \ --enable-xslt \ --with-iconv=/Library/Tenon/PHP \ --with-imap=/Library/Tenon/PHP \ --with-imap-ssl=/usr --with-mcrypt=/Library/Tenon/PHP \ --enable-bcmath \ --enable-sockets \ --with-freetype-dir=/Library/Tenon/PHP \ --enable-bcmath \ --enable-sockets \ --with-freetype-dir=/Library/Tenon/PHP \ --with-ttf --with-gd=/Library/Tenon/PHP --with-xpm-dir=/usr/X11R6
Many of the above options require that extra libraries and header files for certain extensions be installed on your computer in order for the PHP module to compile them in. The iTools PHP module includes all these extra libraries and headers, and installs them into /usr/local. If you wish to compile your PHP module with all of the Tenon extensions, it is recommended that you download the iTools module and install it first. You can then install your custom built module over the Tenon module without any conflict.
Examine the available configure options and decide which extensions you need for your module, and append them to the configure script options. You may wish to use any combination of the options listed above, or remove support for options you do not need. After figuring out which extensions you want, execute 'configure' with your arguments.
./configure --with-apxs2=/Library/Tenon/WebServer/Executables/apxs --with-xml --enable-versioning
configure will now execute, and will check your system to make sure that all of the prerequisites for the extensions that you specified are present. Once completed, it will construct the Makefiles and scripts necessary for the build process.
After doing so, type 'make' at the toplevel source directory. This will initiate the build process. This may take a while, depending on the speed of your machine and how many extensions you included. Once the build process is completed, you will be returned to the command prompt.
Installing Your Custom Module
Type 'make install' at the prompt, and your new custom module will be installed.
Restart Apache and you're all set! You can test your installation by copying the file test.php4 in the 'tests' directory to your server's document root. Type the URL to that file and you should see a page that describes all of the functionality of your custom module in detail.