Setting up PHP with Oracle support

By far one of the most important Web Technologies with Oracle Support is PHP. PHP is a lightweight, server side
language which literally allows for Websites with Oracle integration to be setup within minutes.

This tutorial will go over the basics of getting and compiling PHP on Unix Systems.

For more background information on PHP, you can check the Wikipedia Entry, which is fairly accurate and
up to date:

http://en.wikipedia.org/wiki/PHP

Before starting, you will need to be on a server with the following apps already installed.

  •  Apache 1.x OR 2.x with DSO support you will also need to know the location of the apache bin directory (contains apxs and apachectl) Oracle IAS contains Apache 1.x with DSO support. However it contains the older PHP version 4 which does not support the newer Oracle OCI PHP client. So if you have this, you should follow this guide and upgrade to PHP version 5.
  •  Oracle Client ALONG with all Oracle ProC header files (Which are usually only present in an RDBMS install. If you are installing on a server with only Oracle Client software, you will need to copy these files from a database server of the same hardware type. Header files will have an extension of *.h and are usually located in $ORACLE_HOME/rdbms/public)
  •  Standard Unix Utils, such as gcc and gnu-make click here for more information on building gcc and gnu-make.

1. Get PHP source. You can find the latest source for PHP at http://www.php.net
   The latest version of PHP which we have used with our internal applications is version 5.2.x. Grab the
   appropriate TGZ file and extract it to a staging directory.

2. Once extracted you will need to configure it for your particular environment. cd to the directory,
   verify that the Oracle environment is properly setup. (IE $ORACLE_HOME, $ORACLE_SID, etc are defined correctly).

   Then type the following:

   [Apache 1.x]
   $ ./configure --with-apxs=[path to apache bin]/apxs --with-oci8=$ORACLE_HOME
   OR
   [Apache 2.x]
   $ ./configure --with-apxs2=[path to apache bin]/apxs --with-oci8=$ORACLE_HOME

   You should see a bunch of configuration information scroll past the screen. Fix any errors you may find.

3. Compile PHP. If the configure step successfully finishes, type the following to start the compile:

   $ make

   When the compile is done, you can run a set of optional tests on the newly created executables with:

   $ make test

4. Install PHP. If there are no errors, you can install PHP. This step must be done as the root user. You will
   also need to have the Oracle environment defined for root here.

   $ make install

   By default, PHP installs itself into /usr/local. Make sure that the library libphp5.so is in the
   Apache modules directory.

5. Configure httpd.conf
   Once PHP is installed, you will need to add the following lines to httpd.conf

   LoadModule php5_module        modules/libphp5.so
   AddType application/x-httpd-php .php .phtml

6. At this point, you should be all set restart apache.

7. Test PHP. Create a webpage in your apache document root, call it info.php with the following text:

   
 
   Then open a browser to this page. You should see something like this if everything is ok.