Oracle PDO_OCI PHP install fedora CentOS
Well i run a mix of CentOS and Fedora machines, and at work i needed to run some reports from an Oracle DB. I really don't care much for Oracle, but i needed to get the data, and since i don't like having to do the same thing over again i thought i would just throw together a PHP page and let the user run the canned report themselves. However getting Oracle to install on CentOS and my Fedora boxes was not a simple yum install...
So here are my steps on how i got pdo_oci to install on my machine using PHP 5.2.x
Instant Client
You will first need to download the instant client from oracle website. I am using that link because you may have a x86_64 machine or just a x86. That page will let you choose. You will need to install the following packages
- oracle-instantclient11.2-basic-11.2.0.1.0-1.i386.rpm
- oracle-instantclient11.2-devel-11.2.0.1.0-1.i386.rpm
Run yum -y --nogpgcheck install oracle-instantclient* to install the packages. You can now go to the next section
Oracle Profile
Run the following command to create oracle.sh profile in profile.d directory
cat <<EOF > /etc/profile.d/oracle.sh
export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client/lib/
export ORACLE_HOME=/usr/lib/oracle/11.2/client/lib/
EOF
Then run
[root@ed-mann]# source /etc/profile.d/oracle.sh
Note:
I did change my ORACLE_HOME to /usr/include/oracle/11.2/client. I am not sure if it did anything, i am planning on testing without doing that.
PDO_OCI SRC
To get the oracle PDO driver install on Linux you will need to get the src from pecl
[root@ed-mann tmp]# pecl download pdo_oci
Patch
Then once you have it you need to edit the config.m4 file and add the following after exploding the src look for similar sections
elif test -f $PDO_OCI_DIR/lib/libclntsh.$SHLIB_SUFFIX_NAME.11.2; then
PDO_OCI_VERSION=11.2
also add the following
11.2)
PHP_ADD_LIBRARY(clntsh, 1, PDO_OCI_SHARED_LIBADD)
;;
Again look for a similar area and add that. I may provide a patch. I did see a patch here. But it did not work for me... well it probably would have but by the time i figured this all out i was not using that patch.
Compile
Now you can run phpize and then this configure command
./configure --with-pdo-oci=instantclient,/usr,11.2
Since we are using the instantclient we need to put that also we add what version we are using.
Now you can run make && make install as root
Include File
Create a new file in /etc/php.d named pdo_oci.ini and include the following
; Enable pdo_oci (oracle) extension module
extension=pdo_oci.so
Final Steps
Now you will need to reload/restart Apache. Put phpinfo(); in a page view it from your browser. You should see PDO_OCI listed if not i don't know what went wrong. Leave me a message and i will help if i can.
very usefull
November 17th 2009 at 09:11 am
adobo
Perfect
December 17th 2009 at 03:12 am
thanks!
February 24th 2010 at 06:02 am
internet marketing
Oracle PDO_OCI PHP install fedora CentOS
October 23rd 2010 at 05:10 pm
Changes for x86_64
November 10th 2010 at 09:11 am
linuxine
nice turial
March 7th 2011 at 11:03 pm