1、下载Oracle即时客户端程序包 — Basic: 运行 OCI、OCCI 和 JDBC-OCI 应用程序所需的所有文件
①、打开以下网址(本文以32位版为例):
http://www.oracle.com/technetwork/cn/database/features/instant-client/index-092699-zhs.html(需注册才能下载)
②、下载以下几个文件:
oracle-instantclient-basic-10.2.0.3-1.i386.rpm
oracle-instantclient-devel-10.2.0.3-1.i386.rpm
oracle-instantclient-sqlplus-10.2.0.3-1.i386.rpm
2、安装Oracle即时客户端程序包
rpm -ivh oracle-instantclient-basic-10.2.0.3-1.i386.rpm oracle-instantclient-devel-10.2.0.3-1.i386.rpm oracle-instantclient-sqlplus-10.2.0.3-1.i386.rpm
echo "/usr/lib/oracle/10.2/client/lib/" > /etc/ld.so.conf.d/oracle_client.conf
/sbin/ldconfig
3、安装OCI8 PHP扩展(使用PHP自带的OCI8,假设PHP程序安装在/usr/bin/php/)
yum install libaio
wget http://pecl.php.net/get/oci8-1.4.4.tgz
tar zxvf oci8-1.4.4.tgz
cd oci8-1.4.4/
/usr/bin/phpize CFLAGS="-I/usr/include/oracle/10.2.0.3/client/" CXXFLAGS="-I/usr/include/oracle/10.2.0.3/client/"
./configure --with-php-config=/usr/bin/php-config --with-oci8=instantclient,/usr/lib/oracle/10.2.0.3/client/lib/
make
make install
4、修改PHP配置文件(/etc/php.ini)
在extension_dir = “/usr/bin/php/lib/php/extensions/no-debug-non-zts-20060613/”后增加一行:
extension = "oci8.so"
5、重启httpd
6、创建一个phpinfo.php文件(内容如下)并通过Web访问,如果有“oci8”这一项,则表明安装成功。
var/www/html/ora.php:
<?php
phpinfo();
?>