首先确认你已经安装有oracle 11g,下面是在装有oracle 11g的centos-6 64位配置php与oracle连接的事例。
安装oracle即时客户端
到这里http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html下载oracle-instantclient11.2-basic,oracle-instantclient11.2-devel,oracle-instantclient11.2-sqlplus文件,开始安装:
- rpm -ivh oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm oracle-instantclient11.2-devel-11.2.0.3.0-1.x86_64.rpm oracle-instantclient11.2-sqlplus-11.2.0.3.0-1.x86_64.rpm
- vi /etc/ld.so.conf.d/oracle-lib.conf
加入:
- /usr/lib/oracle/11.2/client64/lib/
安装OCI8 PHP扩展
- cd /tmp
- wget http://pecl.php.net/get/oci8-1.4.7.tgz
- tar xzf oci8-1.4.7.tgz
- cd oci8-1.4.7
- phpize
- ./configure --with-oci8=shared,instantclient,/usr/lib/oracle/11.2/client64/lib/
- make && make install
在/etc/php.ini中加入:
接着使用php -m查看模块是否已经被加载