8i | 9i | 10g | 11g | 12c | 13c | 18c | 19c | 21c | 23c | Misc | PL/SQL | SQL | RAC | WebLogic | Linux
PHP Installation on Oracle Application Server 10g (9.0.4)
This article lists the steps necessary to install and configure PHP with OCI support on AS10g running on Linux. The steps are a summary of the information in the Using PHP with OracleAS 10g document provided by Oracle.
-
Download the current version of PHP from www.php.net and place it in an appropriate directory, like $ORACLE_BASE, then expand it using the following commands as the oracle software owner.
cd $ORACLE_BASE gunzip php-4.3.9.tar.gz tar -xvf php-4.3.9.tar
-
Download the ociheaders.tar file and place it in the "$ORACLE_HOME/rdbms/demo" directory, then expand it using the following command as the oracle software owner.
cd $ORACLE_HOME/rdbms/demo tar -xvf ociheaders.tar
-
Make sure the following environment variables are set by placing them in the oracle users profile.
ORACLE_HOME=/u01/app/oracle/product/904_bi; export ORACLE_HOME LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH PERL5LIB=$ORACLE_HOME/perl/lib/5.6.1:$ORACLE_HOME/perl/lib/site_perl/5.6.1; export PERL5LIB
Adjust the ORACLE_HOME value as necessary.
-
Edit the "$ORACLE_HOME/Apache/Apache/bin/apxs" file, giving a full path for the $CFG_INCLUDEDIR variable as below.
# Before my $CFG_INCLUDEDIR = q(/include); # substituted via APACI install # After my $CFG_INCLUDEDIR = q(/u01/app/oracle/product/904_bi/Apache/Apache/include); # substituted via APACI install
-
Configure and install PHP using the following commands as the oracle software owner.
cd $ORACLE_BASE/php-4.3.9 ./configure --with-apxs=$ORACLE_HOME/Apache/Apache/bin/apxs --prefix=$ORACLE_HOME --with-config-file-path=$ORACLE_HOME/Apache/Apache/conf --with-oci8=$ORACLE_HOME --disable-rpath # Only do the following line if the previous command was successful. make install-sapi
-
Copy the php.ini file to the appropriate directory using the following command.
cp $ORACLE_BASE/php-4.3.9/php.ini-dist $ORACLE_HOME/Apache/Apache/conf/php.ini
-
Uncomment the following two lines from the "$ORACLE_HOME/Apache/Apache/conf/httpd.conf" file.
AddType application/x-httpd-php .php .phtml AddType application/x-httpd-php-source .phps
-
Add the appropriate entries into the "$ORACLE_HOME/network/admin/tnsnames.ora" file for the database connections you wish to make.
-
Restart the HTTP server using one of the following commands as the oracle software owner.
dcmctl restart -ct ohs opmnctl restartproc ias-component=HTTP_Server
Alternatively, the following commands allow you to stop then start the HTTP server.
dcmctl stop -ct ohs dcmctl start -ct ohs opmnctl stopproc ias-component=HTTP_Server opmnctl startproc ias-component=HTTP_Server
-
Test PHP by creating a file called "$ORACLE_HOME/Apache/Apache/htdocs/test.php" with the following contents.
<?php phpinfo(); ?>
Loading this page in a browser using a URL like "http://server:port/test.php" should produce the PHP info page and list the OCI8 component as enabled.
-
Test the OCI extensions by creating a file called "$ORACLE_HOME/Apache/Apache/htdocs/testOCI.php" with the following contents, adjusting the connection details as required.
<?php $conn = OCILogon("scott", "tiger", "DEV"); $sql = OCIParse($conn, "select sysdate as current_date from dual"); OCIExecute($sql, OCI_DEFAULT); if (OCIFetch($sql)) { echo "Current Date: ".OCIResult($sql, "CURRENT_DATE"); } OCILogoff($conn); ?>
Loading this page in a browser using a URL like "http://server:port/testOCI.php" should produce the current datetime from the Oracle server.
For more information see:
Hope this helps. Regards Tim...