« May 23, 2007 | Main | June 11, 2007 »

June 1, 2007 Archives

June 1, 2007

Upgrade PHP with Oracle Application Server on Linux

Oracle includes PHP with its mid-tier Application Server 10g Release 3 allowing you to use the same web server for PHP and for J2EE applications.

PHP is enabled by default. The Oracle HTTP Server document root is

$ORACLE_HOME/Apache/Apache/htdocs
Files with .php or .phtml extensions in this directory will be executed by PHP. Files with a .phps extension will be displayed as formatted source code.

Version 10.1.3.0 of the Application Server (AS) comes with PHP 4.3.11. The AS 10.1.3.2 patchset adds PHP 5.1.2. If you have a strong need to use a different version of PHP without installing a new web server, you may be able to compile your own PHP release.

Note: Changing the version of PHP in AS is not supported (and hence is not recommended) but is technically possible in some circumstances. For any AS support calls, regardless of whether they are PHP related, Oracle Support will ask you to revert the changes before beginning investigation.

The technical problem faced with building PHP is that the Oracle libraries for AS do not include header files. This can be overcome by linking PHP with Oracle Instant Client but care needs to be taken so that AS itself does not use the Instant Client libraries. Otherwise you will get errors or unpredictable behavior.

These steps are very version and platform specific. They may not be technically feasible in all deployments of AS.

A previous installation of AS 10.1.3 is assumed. To install a new version of PHP:

1. Logon as the oracle user and change to the home directory
cd $HOME
2. Download the Oracle 10.2.0.3 Basic and SDK Instant Client packages from the Instant Client page on the Oracle Technology Network, http://www.oracle.com/technology/tech/oci/instantclient/instantclient.html.

3. Extract the ZIP files:
unzip instantclient-basic-linux32-10.2.0.3-20061115.zip
unzip instantclient-sdk-linux32-10.2.0.3-20061115.zip
4. Change to the Instant Client directory and symbolically link libclntsh.so.10.1:
cd instantclient_10_2
ln -s libclntsh.so.10.1 libclntsh.so
The Instant Client RPMs could also be used, in which case this last step is unnecessary.

Be wary of having Instant Client in /etc/ld.so.conf since Instant Client libraries can cause conflicts with AS. The opmnctl tool may fail with the error Main: NLS Initialization Failed!!.

5. Download PHP 5.2.2 from http://www.php.net/downloads.php and extract the file:
cd $HOME
tar -jxf php-5.2.2.tar.bz2
6. Set the ORACLE_HOME environment variable to your AS install directory:
export ORACLE_HOME=$HOME/product/10.1.3/OracleAS_1
7. Shutdown the HTTP Server:
$ORACLE_HOME/opmn/bin/opmnctl stopproc ias-component=HTTP_Server
8. Edit $ORACLE_HOME/Apache/Apache/conf/httpd.conf and comment out the PHP 4 LoadModule line by prefixing it with #:
#LoadModule php4_module             libexec/libphp4.so
If you had enabled PHP 5 for AS 10.1.3.2, the commented line will be:
#LoadModule php5_module             libexec/libphp5.so
Also, backup $ORACLE_HOME/Apache/Apache/libexec/libphp5.so since it will be replaced.

9. Set environment variables required for the build to complete:
export PERL5LIB=$ORACLE_HOME/perl/lib
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export CFLAGS=-DLINUX
There is no need to set CFLAGS if you have AS 10.1.3.2. It is needed with AS 10.1.3.0 to avoid a duplicate prototype error with gethostname() that results in compilation failure.

10. Configure PHP:
cd php-5.2.2
./configure 
  --prefix=$ORACLE_HOME/php 
  --with-config-file-path=$ORACLE_HOME/Apache/Apache/conf 
  --with-apxs=$ORACLE_HOME/Apache/Apache/bin/apxs 
  --with-oci8=instantclient,$HOME/instantclient_10_2 
  --enable-sigchild
With the older AS 10.1.2 and older Instant Client releases, some users reportedly also specified --disable-rpath.

11. Make and install PHP
make
make install
Installation copies the binaries and updates $ORACLE_HOME/Apache/Apache/conf/httpd.conf, automatically adding the line:
LoadModule php5_module        libexec/libphp5.so
12. Backup and update $ORACLE_HOMEApache/Apache/conf/php.ini with options for PHP 5.2.2, for example all the new oci8 directives. Refer to $HOME/php-5.2.2/php.ini-recommended for new options.

13. The HTTP Server can now be restarted:
$ORACLE_HOME/opmn/bin/opmnctl startproc ias-component=HTTP_Server
Reminder: following these steps invalidates all support for AS, not just for the PHP component, and should not be used in production environments.

These steps are based on those that Michael Sekurski from one of our infrastructure groups sent me a while back.  They will appear in the next release of the Undergound PHP and Oracle Manual so let me know of any suggestions.

About June 2007

This page contains all entries posted to PHP and Oracle: Christopher Jones in June 2007. They are listed from oldest to newest.

May 23, 2007 is the previous archive.

June 11, 2007 is the next archive.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type and Oracle