配置PHP与Oracle数据库连接

首先确认你已经安装有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文件,开始安装:

  1. 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
  1. vi /etc/ld.so.conf.d/oracle-lib.conf

加入:

  1. /usr/lib/oracle/11.2/client64/lib/
  1. ldconfig

安装OCI8 PHP扩展

  1. cd /tmp
  2. wget http://pecl.php.net/get/oci8-1.4.7.tgz
  3. tar xzf oci8-1.4.7.tgz
  4. cd oci8-1.4.7
  5. phpize
  6. ./configure --with-oci8=shared,instantclient,/usr/lib/oracle/11.2/client64/lib/
  7. make && make install

在/etc/php.ini中加入:

  1. extension = "oci8.so"

接着使用php -m查看模块是否已经被加载

标签:PHP 发布于:2019-11-23 19:20:36