Installing Oracle PHP extensions in SUSE Linux
We work a lot with SLES, Oracle and PHP. When installing SLES on your server there is an option in software selection under “Primary Functions” that says “Oracle Server Base”. This copies the scripts required to get Oracle up and running once it has been successfully installed. Unfortunately it does not include the PHP extensions that are required to talk to the Oracle database. These have to be manually added. This is not really a failing of the installer as Oracle must be installed and configured on your server before you can install the PHP extension.
There are a couple of files that you need to get to make this work. First, you need the PECL extension for Oracle. PECL is a repository for PHP extension. Go to http://pecl.php.net/package/oci8 and download the latest version. You will also need the php-devel package for your version of PHP. Unfortunately this is not included in the standard SLES distribution. To get this you will have to download the appropriate SLES SDK. Head on over to http:// http://download.novell.com and find the SUSE Linux Enterprise Server SDK that matches your server. I found the files that I needed in a DVD labelled “SLE-11-SP1-SDK-DVD-i586-GM-DVD1.iso”.
Extract the files readline-devel-5.2-147.9.13.i586.rpm, libxml2-devel-2.7.6-0.1.37.i586.rpm, zlib-devel-1.2.3-106.34.i586.rpm and php5-devel-5.2.6-50.24.1.i586.rpm from DVD and copy them to your server.
In order to install the php5-devel package we will need to satisfy a few dependencies. Install the four packages you copied from the SDK in the order shown.
rpm -iv readline-devel-5.2-147.9.13.i586.rpm
rpm -iv zlib-devel-1.2.3-106.34.i586.rpm
rpm -iv libxml2-devel-2.7.6-0.1.37.i586.rpm
rpm -iv php5-devel-5.2.6-50.24.1.i586.rpm
Next, unpack the unpack oci-8 library and change to the appropriate directory:
tar xfvz oci8-1.4.6.tgz
cd oci8-1.4.6
You will need to create the configure script that creates the Makefile for your environment. Enter the command:
phpize
If everything is in place you will find a file called configure in the current directory. After the phpize script has created your configure script run the command:
echo $ORACLE_HOME
and ensure that your ORACLE_HOME environment variable is pointing to your Oracle installation. If it is incorrect then edit /etc/profile.d/oracle.sh, make the change then restart the Oracle server (rcoracle restart).
Now run the configure script to create your Makefile:
./configure -with-oci8=shared,$ORACLE_HOME
If you get any errors when running the configure script it usually means that there are missing libraries. These missing libraries will need to be installed. Locate the RPM packages for the missing libraries on the SDK and install them. Build and install the oci8 library by running:
make install
Watch the output from the makefile to make sure there are no errors. For 32-bit versions of SLES the file oci8.so should now be in the correct place for use. If you have the 64-bit version of SLES you will need to copy the oci8.so file to the right library location. Enter the command:
cp /usr/lib/php5/extensions/oci8.so /usr/lib64/php5/extensions/
You will need to let PHP know to use the Oracle oci extensions. Edit your php.ini:
vi /etc/php5/apache/php.ini
Add the line “extension=oci8.so” after the line “extension_dir = /usr/lib64/php5/extensions” and save the ini file. It does not really matter where you put this line in the ini file but keeping it close to the extension_dir directive keeps things neat and tidy. Restart the Apache web server:
rcapache2 restart
Finally, test it out. Create a one line test PHP script in your document root and launch it from the browser.
<? Phpinfo() ?>
Scroll down the page and look for the oci8 extensions.
Related Articles
Oct 04th, 2024
Ensuring Business Continuity with SUSE Linux
Jun 04th, 2024
How to upgrade to SAPHanaSR-angi
Sep 05th, 2023
No comments yet