The leading edge of scripting languages and Oracle Database brought to you by the Data Access Development team

  • php
    March 23, 2011

Building PHP 5.3 with Oracle HTTP Server 11g

Christopher Jones
Senior Principal Product Manager

This post has instructions for building PHP with Oracle HTTP Server 11g (OHS). It is based on the older note Using PHP with Oracle HTTP Server 11g.

I used an uncommon OS, but the instructions should be very similar for other systems. This post is in the "blogging it so I can find it again" category.

I recently had the so-called "pleasure" of building PHP on HP/UX Itanium. This is a platform that I'm very glad to see Oracle's announcement: Oracle Stops All Software Development For Intel Itanium Microprocessor

I get the impression that not a lot of people in the PHP community are using Itanium. There are enough warnings during PHP compilation that would make me extremely uncomfortable using it for production applications. A PHP on Itanium installation bug that I logged long ago has not been patched, indicating to me that not many PHP people are investing time in the platform. I can't recommend using Itanium platform for PHP.

Anyway, I had a need and here are the steps for posterity.

Steps to build PHP 5.3.5 with OHS 11g (with reference to HP/UX Itanium 64 bit)

1. Check OS & compiler

    $ uname -a
HP-UX B.11.31 U ia64 2921109885 unlimited-user license
$ cc --version
cc: HP C/aC++ B3910B A.06.23 [May 18, 2009]

I saw various issues with the whole HP/UX build environment, including total compilation failure when using an older (different??) compiler than this.

2a. Set the Oracle environment. The Oracle home contains an instance of OHS.

     export ORACLE_HOME=/path/to/your/oracle-home
export ORACLE_INSTANCE=$ORACLE_HOME/instances/instance1

2b. Set the PHP compiler environment.

     export CFLAGS='+O2 +DD64'
export CC=/bin/cc

You'll need to check and experiement with the best compiler options. On Itanium +DD64 is needed to create a 64bit binary usable with OHS.

3. Download and extract the Oracle InstantClient SDK ZIP file from http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html e.g.: http://download.oracle.com/otn/hp/instantclient/111070/sdk-

     unzip sdk-

4. Copy the new header files

     cp instantclient_11_1/sdk/include/*.h $ORACLE_HOME/rdbms/demo

5. Extract the php-5.3.5 bundle to a working directory:

     gunzip php-5.3.5.tar.gz
tar -xf php-5.3.5.tar

6. Change to the extracted PHP directory:

     cd php-5.3.5

7. Edit PHP's 'configure' and change 'sl' to 'so' in the 'hpux' case at about line 3720: (This is the Itanium specific part of the patch in PHP PECL Bug 15016)

     case $host_alias in

8. If using PHP 5.3.6 or earlier, edit PHP's 'configure' script and change both occurrences of:

      APACHE_VERSION=`expr $4 \* 1000000 + $5 \* 1000 + $6`


      APACHE_VERSION=`expr $6 \* 1000000 + $7 \* 1000 + $8`

This step is missing from the OHS 11g PHP installation instructions. It is needed because OHS's Apache reports its error number differently. See PHP bug 54084, which I just fixed in the 5.3 and trunk branches of the PHP source code.

9. Clean up if you are repeating the steps and re-running 'configure' with different options:

      make distclean
rm -rf config.cache autom4te.cache

10. Configure & build PHP with whatever options:

      ./configure --disable-all --with-apxs2=$ORACLE_HOME/ohs/bin/apxs \
--with-oci8=$ORACLE_HOME --disable-rpath \
--prefix=$ORACLE_HOME --with-config-file-path=$CONFIG_FILE_PATH

This produces a bunch of compiler warnings that would make me very uncomfortable to have running in production.

Notice I used --disable-all. The system libraries are a little different on Itanium and I didn't have access to libraries such as libxml2. Perhaps by working out the installation steps or by building third-party software bundles you could get the dependencies for other PHP extensions.

11. Copy a default php.ini file:

      cp php.ini-devlopment $CONFIG_FILE_PATH/php.ini


      cp php.ini-production $CONFIG_FILE_PATH/php.ini

12. Edit $CONFIG_FILE_PATH/php.ini and add a timezone line (this is mandatory for PHP 5.3):


13. Edit $CONFIG_FILE_PATH/php.ini and add 'E' to 'variables_order' so PHP's run-tests.php passes the Oracle environment correctly when running tests:

      variables_order = "EGPCS"

This can be removed later.

14. Modify run-tests.php and change 60 to 600. This prevents long Oracle tests from timing out.

15. Edit ext/oci8/tests/details.inc and set the SYSTEM password and connection string to your Oracle DB.

16. Set the PHP environment so PHP tests don't try to email results to the world:

      export NO_INTERACTION=no

17. Test the PHP command-line binary:

      make test

The OCI8 tests can be run with:

      make test TESTS=ext/oci8

18. Investigate failed tests. Also compare the results with 64 bit Linux results. A significant number of tests do pass on Itanium, which gives some hope that much of the PHP code base works, even if it is delicate and likely to be prone to memory corruption issues.

19. If all is OK, install the PHP binaries:

      make install

20. Edit $CONFIG_FILE_PATH/httpd.conf and add a line:

     AddType application/x-httpd-php .php 

21. Restart OHS:

     cd $ORACLE_INSTANCE/bin
./opmnctl start
./opmnctl stopproc ias-component=ohs1
./opmnctl startproc ias-component=ohs1

22. Create a phpinfo file:

      echo '<?php phpinfo(); ?>' > $ORACLE_INSTANCE/config/OHS/ohs1/htdocs/phpinfo.php

23. Check phpinfo on the port OHS is configured for. In my case it was port 7777:


24. Create and run some OCI8 scripts in $ORACLE_INSTANCE/config/OHS/ohs1/htdocs at your leisure.

To repeat my earlier warning, I don't recommend using PHP on Itanium.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.