I am currently working on a PHP project that requires using an Oracle server as the database. I tried setting up the Oracle PHP extensions directly on my development machine (MacOSX) but failed after a few tries. I also managed to ruin my Homebrew-PHP setup which brought me more joy.
So I ended up using Vagrant which is what I should have done in the first place. So I booted up a Vagrant box with CentOS 6.4 64bit.
This tutorial assumes that you have already installed
php
and other packages (e.g. php-pdo
) you normally need. This was also tested with an installation of Oracle 11g Express. I’m not sure if this will work for higher versions.Dependencies
Oracle
Installing Oracle is easy. You can follow this tutorial by David Ghedini in installing Oracle 11g Express.
Development packages
InstantClient
Download Oracle InstantClient RPM files here. Put these files in your server. Download the basic and devel packages.
- Basic: oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm
- Devel: oracle-instantclient11.2-devel-11.2.0.3.0-1.x86_64.rpm
Install the downloaded rpm files:
Create a file inside
/etc/profile.d
named oracle.sh
and put this as the content:
And run it so we’ll have
LD_LIBRARY_PATH
as an environment variable.PDO_OCI
Download the PDO_OCI source using
pecl
.
Inside the
PDO_OCI-1.0
folder, edit the file named config.m4
.
Find a pattern like this near line
10
and add these 2 lines:
Find a pattern like this near line
101
and add these lines:
Build and install the extension.
To enable the extension, add a file named
pdo_oci.ini
under /etc/php.d
and put this as the content:
Validate that it was successfully installed.
You should see something like this in the output:
OCI8
Download the OCI8 source using
pear
Build and install the extension.
To enable the extension, add a file named
oci8.ini
in /etc/php.d
with this content:
Validate that it was successfully installed.
You should see something like this:
Finishing up
Do not forget to restart your web server (e.g. Apache). You can double check with
phpinfo()
if the extensions were successfully installed.
This tutorial wouldn’t have been possible without these references:
- Oracle PDO_OCI PHP install fedora CentOS
- Linux RedHat – Oracle installing pdo_oci and oci8 modules
- HOWTO install Oracle OCI8 on RHEL / CentOS / Fedora
Source :http://shiki.me/blog/installing-pdo_oci-and-oci8-php-extensions-on-centos-6-4-64bit/
Posting Komentar