Build PHP with OCI8

user-pic
Vote 0 Votes

Environment: CentOS 5.5 x64

1. Download Oracle Instant Client basic and devel rpm and install
(You need to register an oracle account first)
rpm -ivh oracle-instantclient11.2-basic-11.2.0.1.0-1.x86_64.rpm
rpm -ivh oracle-instantclient11.2-devel-11.2.0.1.0-1.x86_64.rpm

2. Downlaod Extension for Oracle Database from PECL and install
wget http://pecl.php.net/get/oci8-1.4.3.tgz
pecl install oci8-1.4.3.tgz

3. Move oci8.so to extension_dir (see your php.ini)
cp /usr/local/lib/php/extensions/no-debug-non-zts-20060613/oci8.so /usr/lib64/php/modules

4. add extension=oci8.so to php.ini
echo extension=oci8.so >> /usr/local/etc/php.ini

Verifying the oci8 extension is work
# php -i | grep OCI
OCI8 Support => enabled

Easy Connect Example:
$conn = oci_connect('user', 'password', '//172.29.2.2/service_name');
// Use lsnrctl services in Oracle to list existing service name
$stid = oci_parse($conn, "select id from table");
oci_execute($stid, OCI_DEFAULT);
while ($arr = oci_fetch_array($stid, OCI_ASSOC)) {
echo "$arr[id].\n";
}

ref. Installing PHP and the Oracle Instant Client for Linux and Windows
PHP Oracle FAQThis is a featured page
PHP: oci_connect - Manual

About this Entry

This page contains a single entry by Pank published on September 2, 2010 7:48 PM.

PieTTY 0.4.00b11 was the previous entry in this blog.

NextTV Player is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Monthly Archives