PHP下的Oracle客户端扩展(OCI8)安装教程

最近的项目需要用PHP访问oracle数据库,不得不在linux下给PHP安装oci8扩展。PHP也可以使用pdo访问oracle数据库,但还是需要安装客户端。

首先到oracle官网的这个页面下载相关的文件,注意要连数据库服务器的版本,一定要对应,否则安装成功也会连不上,同时也要区分32位、64位服务器,比如我要连的数据库服务器是oracle10.2.0.4,64位主机,那么我要下载下面三个文件

代码如下:
sqlplus-10.2.0.4-1.x86_64.rpm

1.用以下命令安装

代码如下:
sqlplus-10.2.0.4-1.x86_64.rpm

2.安装OCI8 PHP扩展

代码如下:
PHP.net/get/oci8-1.3.5.tgz

3.然后执行命令

代码如下:
PHP5/bin/PHPize CFLAGS=/usr/lib/oracle/11.2/client64/ CXXFLAGS=/usr/lib/oracle/11.2/client64/ # ./configure --with-PHP-config=/usr/local/PHP5/bin/PHP-config --with-oci8=instantclient,/usr/lib/oracle/11.2/client64/lib/ # make # make install(这里多运行几次,直到出现如下提示)

[root@webserver02 oci8-1.3.5]# make install
/bin/sh /root/oci8-1.3.5/libtool --mode=install cp ./oci8.la /root/oci8-1.3.5/modules
cp ./.libs/oci8.so /root/oci8-1.3.5/modules/oci8.so
cp ./.libs/oci8.lai /root/oci8-1.3.5/modules/oci8.la
PATH="$PATH:/sbin" ldconfig -n /root/oci8-1.3.5/modules

Libraries have been installed in:
/root/oci8-1.3.5/modules

If you ever happen to want to link against installed libraries in a given directory,LIBDIR,you must either use libtool,and specify the full pathname of the library,or use the `-LLIBDIR' flag during linking and do at least one of the following: - add LIBDIR to the `LD_LIBRARY_PATH' environment variable during execution - add LIBDIR to the `LD_RUN_PATH' environment variable during linking - use the `-Wl,--rpath -Wl,LIBDIR' linker flag - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for more information,such as the ld(1) and ld.so(8) manual pages. ---------------------------------------------------------------------- Installing shared extensions: /usr/local/PHP5/lib/PHP/extensions/no-debug-zts-20090626/ # cd /usr/local/PHP5/lib

4.创建ext目录

代码如下:
把oci8.so文件拷贝PHP.ini 的ext目录里面
代码如下:
.so /usr/local/PHP5/lib/ext/

5.在PHP.ini里面加上extension=oci8.so

如下:

代码如下:
PHP5/lib/ext" extension = "oci8.so" session.save_path = "/tmp/PHP" oci8.privileged_connect = on

重启apache服务:

代码如下:

刷新测试页面。发现oci8出现了,则大功告成.

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...