Upgrade PHP with Oracle Application Server on Linux
By cj on Jun 01, 2007
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/htdocsFiles 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 $HOME2. 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-sdk-linux32-10.2.0.3-20061115.zip4. Change to the Instant Client directory and symbolically link libclntsh.so.10.1:
ln -s libclntsh.so.10.1 libclntsh.soThe 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:
tar -jxf php-5.2.2.tar.bz26. Set the ORACLE_HOME environment variable to your AS install directory:
export ORACLE_HOME=$HOME/product/10.1.3/OracleAS_17. Shutdown the HTTP Server:
$ORACLE_HOME/opmn/bin/opmnctl stopproc ias-component=HTTP_Server8. 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.soIf you had enabled PHP 5 for AS 10.1.3.2, the commented line will be:
#LoadModule php5_module libexec/libphp5.soAlso, backup $ORACLE_HOME/Apache/Apache/libexec/libphp5.so since it will be replaced.
9. Set environment variables required for the build to complete:
export CFLAGS=-DLINUXThere 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:
--enable-sigchildWith the older AS 10.1.2 and older Instant Client releases, some users reportedly also specified --disable-rpath.
11. Make and install PHP
make installInstallation copies the binaries and updates $ORACLE_HOME/Apache/Apache/conf/httpd.conf, automatically adding the line:
LoadModule php5_module libexec/libphp5.so12. 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_ServerReminder: 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 Underground PHP and Oracle Manual so let me know of any suggestions.