Q: Can I compile my own custom PHP module for Apache?

A: If neither the provided PHP module nor the alternative PHP modules in the vinstall library suit your needs, you might consider compiling your own custom PHP module for Apache.

If your Freedom server provides root access, this is a fairly simple thing to do. However, it's important to understand the implications of doing so:

First of all, the provided PHP module does not take any of your disk space because it exists as symbolic links (symlinks) to the actual files in /usr/virtual/share. Compiling your own PHP module will eat up a bit of your virtual disk space.

Also, by compiling your own PHP module, you cross a support boundary.  Our technical support staff can assist you with PHP-related issues only when you are running our provided module. You are welcome to create your own PHP module, but understand that doing so is outside of our support boundary. We can't provide you with technical support in creating or using custom Apache modules.   

Finally, anytime you replace a provided feature like one into your own hands, you assume full responsibility for maintaining it.  In other words, we will occasionally make updates to the provided PHP module which lives in /usr/virtual/share, but we will not make any upgrades to your custom PHP module.  

That being said, the following is an example of how to compile your own PHP module.

Step 1: Download the PHP source code you wish to use.   

Note that many of PHP's optional features require that other pieces of source code or software packages be installed, so you'll need to obtain those as well.  In this example, we assume that you've extracted PHP's source into a /usr/local/src directory.

Step 2: Configure PHP.

The easiest way to build PHP is to use the Apache Extension tool - APXS.  For example, you could run this command from the directory in which you've extracted the PHP source:

> ./configure --with-apxs=/usr/local/www/bin/apxs --with-mysql=/usr/local/ --with-gd=/usr/local/ --with-freetype --with-imap

Step 3: Build PHP.  

Assuming you configured the source successfully, you can then do the build by running the make command from the directory in which you've extracted the PHP source:

> make

Step 4: Remove the existing PHP module.

The provided PHP module exists as a symlink in /usr/local/www/libexec. To replace it, you will need to remove this symlink as root:

> rm /www/libexec/libphp4.so

Step 5: Install the new module.  

You can then install the module by running make install from the PHP source directory:

> make install

Step 6: Test your Apache configuration.

Before restarting your Apache configuration, you can check to see if things look good so far by running:

> apachectl configtest

Step 7: Restart Apache.  

If you don't see any configuration errors, restart Apache by running:

> apachectl restart

You should now be running your custom PHP module.