Tenon Intersystems Please see text links at bottom of page for navigation Please see text links at bottom of page for navigation
Please see text links at bottom of page for navigation Please see text links at bottom of page for navigation Please see text links at bottom for navigation
Please see text links at bottom of page for navigation

Search tenon.com

Thanks to:
ht://dig icon


iTools 6: How To Build Custom PHP Modules

Overview

This document explains the process of compiling mod_php4 for iTools 6 (Apache 1.3). 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.

The PHP Group does not officially support PHP on the Mac OS X platform. They claim that the PHP module on the Mac OS X platform lacks certain key features and, due to a number of issues with GNU libtool, does not build out-of-the-box. PHP 4.3.0, which is scheduled for August, will be officially supported on Mac OS X.

For a more technical discussion on the build issues with Mac OS X, please consult the following PHP bug report:

http://bugs.php.net/bug.php?id=14483

Building PHP4

This is the build process Tenon has used with version 4.2.1 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-apxs'. apxs is a perl script that is bundled with the standard Apache that is used to compile dynamically loadable modules that conform to the Apache version that is currently installed on your computer. The apxs script passes the appropriate options to the compiler during the build process that will enforce that the module be built with the same specifications that Apache was built to.

iTools includes an apxs script, which is located in /usr/sbin. When configuring PHP, we need to specify the '--with-apxs=/usr/sbin/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:

--with-ldap=/usr/local --with-xml --enable-shared --enable-versioning 
--enable-trans-id --enable-track-vars --enable-ftp --with-mysql 
--with-pdflib=/usr/local --with-zlib-dir=/usr/local --with-png-dir=/usr/local 
--with-jpeg-dir=/usr/local --with-gd=/usr/local --with-tiff-dir=/usr/local 
--with-apxs=/usr/sbin/apxs --enable-openbase_module 
--with-pgsql=/Library/PostgreSQL --with-curl=/usr/local 
--with-pspell=/usr/local/pspell --enable-exif --enable-wddx --enable-mbstring 
--enable-mbstr-enc-trans --with-iconv=/usr/local/iconv --with-mcrypt=/usr/local 
--with-bcmath

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.

For example:

./configure --with-apxs=/usr/sbin/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 configure has finished, you will notice a script called 'libtool' in the top level source directory. This script is used to compile the module, but the standard version has bugs which will cause problems during the build process. You can download a patched version from the following URL's:

http://www.tenon.com/~downloads/libtool.php.tar.gz
http://mirror.tenon.com/libtool.php.tar.gz

After untarring the file, you will have a 'libtool.works' script. Copy this over the libtool script that was generated by configure.

Almost ready to build. We need to modify one source file in order to fix a multiple definition error. In your favorite command line text editor, open the file zend_language_scanner.c inside the Zend directory from the toplevel. Go to line 2725 and comment out the line that says 'char *yytext;'. This can be done by placing two / characters consecutively in front of the statement (C++ style), or by surrounding the statement with a /* and */ (C style). Save the file.

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

On most other systems, we would be able to install the module by issuing 'make install' at the command prompt, and restarting Apache. Unfortunately, it's not that easy on Mac OS X.

First, the resulting module file has been produced in a hidden directory called '.libs'. Copy the file 'libphp4.dylib' from that directory into the 'libs' directory, and rename the file to have a '.so' extension.

Next, open the file 'config_vars.mk' in your favorite text editor, and near the top of the file you will see a variable called 'APACHE_INSTALL'. At the end of the line, you will see the string 'libs/libphp4.dylib'. Change the libphp4.dylib to libphp4.so, and save the file.

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.


| Tenon Home | Products | Order | Contact Us | About Tenon | Register | Tech Support | Resources | Press Room | Mailing Lists |

Copyright©2000 Tenon Intersystems, 1123 Chapala Street, Santa Barbara, CA 93101. All rights reserved. Questions about our website - Contact webmaster@tenon.com.


Powered By iTools

Tenon Home  Tenon Home  Tenon Home  Tenon Home Product Info  Tenon Ordering Contact About Register Support Resources Press Mailing Lists