I have to tell you, besides docman populate this is the best plugin for Docman. My main gripe with docman and other download components is that when you have more than 5 files, no one wants to scroll through 5 pages to view them. -DOCman forum user
Print

Oracle OCI8 PHP Installation

Written by Omar Ramos | Admin. Posted in Oracle

This is a reprint of a post I made on the Atomic Rocket Turtle Forums on September 15, 2008:

OK, I've accomplished my main goal for the day :-).

I've gotten the OCI8 PHP Module installed along with the Oracle Instant Client Library so now I can make calls to our Oracle database within PHP.

Awesome!

So this is what I needed to do.

Step 1: Download Oracle Instant Client Basic AND SDK Packages

To download Oracle Instant Client first go to:

http://www.oracle.com/technology/software/tech/oci/instantclient/index.html

And go to the download page for the version of Linux you are running (I'm running on x86_64, but you may be using x86) by clicking on the appropriate link (I clicked on "Instant Client for Linux x86-64").

The download page has two requirements: first you must accept the Oracle Terms, and second you're going to need an Oracle.com account (which is free, but you just need to register first). If you don't have an Oracle.com account yet, no worries as you'll be asked about it once you try and download a file.

You'll see a couple of different version for the Oracle Instant Client: Version 11.1.0.6.0, 10.2.0.4, etc.). Now I'm not 100% certain, but I am pretty sure that the 11.1.0.6.0 version dropped support for Oracle 9i (since I remember trying it out on my Windows PC with PHP and it couldn't connect to our database) so I decided to use 10.2.0.4 instead.

I downloaded both the Basic and the SDK Instant Client Packages in RPM format (since we have a Redhat server).

I do not know if you can use a wget to download the files or not, but what I did was download them both to my local Windows PC, and then SFTP them over to my home directory on the Plesk server.

Step 2: Install the Oracle Instant Client Basic and SDK Packages

With an RPM, the installation was fairly simple, and I am pretty sure installing from the zip file would be almost as easy (if somebody knows the procedure for the zip file it'd be nice of you to add a comment).

To install the Basic and SDK packages from SSH just go into your home directory (or wherever you placed the files) and then type in: rpm -ivh oracle-instantclient-basic-10.2.0.4-1.x86_64.rpm rpm -ivh oracle-instantclient-devel-10.2.0.4-1.x86_64.rpm

That will create a few different folders, but specifically the Oracle Instant Client files will be installed here: /usr/lib/oracle/10.2.0.4/client64/lib

You've now installed the Oracle Instant Client Basic Package and the SDK which you'll need to install the PHP OCI8 module.

Step 3: Download the OCI8 Extension from PECL

With PECL you can go about this a couple of different ways, but I just went to the OCI8 Extension Page:

http://pecl.php.net/package/oci8

And then downloaded the latest version of the extension to my local PC.

Then I created a folder named "oci8" on my Desktop and used 7-zip to extract the contents of the tgz file into the oci8 folder.

So in the oci8 folder on your Desktop you should have the following: A package.xml file A oci8-1.3.4 folder with some files inside.

Step 4: Build the PHP OCI8 Module

Now copy the oci8 folder to your home directory using a SFTP program like WinSCP.

I then followed this person's instructions, which I'll be going over here (I just wanted to provide some of the source for my success):
http://www.php.net/manual/en/oci8.setup.php#83323

Using SSH go into the oci8 folder that you just SFTP'd into your home directory and run the following command: pecl build

I'm trying to remember exactly what happened right now from memory, but I am pretty sure at this point that you will be prompted for the location of ORACLE_HOME. It really doesn't matter what you enter at this point though because it really doesn't take your input as it should so just press enter and let it take it's course.

After that's done run the following command: cd oci8-1.3.4

and then type in: ./configure --with-oci8=instantclient,/usr/lib/oracle/10.2.0.4/client64/lib and push enter.

 

You'll see quite a bit of output but you shouldn't run into any errors (I initially ran into an SDK issue because I hadn't download the Oracle Instant Client SDK Package).

Once that has completed type in the following: make

Which I suppose creates the oci8.so file.

And you've successfully built the oci8 PHP module :-).

Step 5: Install the OCI8 PHP Module

Now that everything has been built, there should be a new folder named "modules" in the oci8-1.3.4 folder.

cd into the modules directory and if you do an ls to see the folder contents you will see the oci8.so module. What you want to do now is copy it into the location where your other PHP modules are stored.

In my case this location is: /usr/lib64/php/modules/

So to do the copy from within the modules folder type in: cp oci8.so /usr/lib64/php/modules

Next, you have to add an .ini entry to your php.d folder so that php will try and load this extension when it starts up.

Go to your php.d folder by typing in: cd /etc/php.d

Then you are going to want to create a new oci8.ini file which you can do by typing in: vi oci8.ini

First press "i" on your keyboard to change the vi text editor to insert mode so that you can start typing and then type in: ; Oracle Instant Client Shared Object extension=oci8.so

Now press ":" (colon) and then "w" to write your changes to disk and then press ":" and then "q" to quit vi and go back to the command line. If you do an ls at this point you should see the new oci8.ini there.

You've successfully installed the OCI8 PHP Module into PHP, just one more step!

Step 6: Restart Apache to Load New Changes

To restart Apache all you need to do is type in: /etc/init.d/httpd restart

Everything should be working and the OCI functions should be available to your PHP scripts now. If you'd like to test further, you can create a phpinfo file (and then use Ctrl+F to do a search for oci8 in the output) and also try using the OCI functions by making a connection to your database and running a query.