centos上对php安装oci8扩展的支持

1.先像上一篇文章描述的那样安装好oracle client

2.对php增加oci8拓展

(1)用pecl安装oci拓展

pecl install oci8

一路自动编译下去之后,突然卡在这个地方报错了

checking Oracle Instant Client SDK header directory... configure: error: Oracle Instant Client SDK header files not found
ERROR: `/var/tmp/oci8/configure --with-oci8=instantclient,/usr/lib/oracle/11.2/client64/lib' failed

 

缺少SDK就去官网下SDK呗,于是又到官网地址 http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html

找到以下内容的sdk devel rpm包

*Instant Client Package - SDK: Additional header files and an example makefile for developing Oracle applications with Instant Client
Download oracle-instantclient11.2-devel-11.2.0.3.0-1.x86_64.rpm (609,139 bytes) (cksum - 2701969031)

使用 

rpm -ivh oracle-instantclient11.2-devel-11.2.0.3.0-1.x86_64.rpm

进行默认的安装即可

 

重新执行 pecl install oci8

出现如下提示则代表安装扩展的过程完全成功,如出现其他提示,请返回重做上面的步骤

Build process completed successfully
Installing '/usr/lib64/php/modules/oci8.so'
install ok: channel://pecl.php.net/oci8-1.4.9
configuration option "php_ini" is not set to php.ini location
You should add "extension=oci8.so" to php.ini

 

 

(2)对php.ini进行设置,php.ini文件底部增加oci8.so

[oracle oci8]
extension=oci8.so

然后使用 service php-fpm restart重启php之后,查看phpinfo可见oci8成功开启,设置全部完成.

Read More

centos6.2 64位上配置oracle客户端

新项目为了使用php连接oracle数据库,对几台php服务器进行了oracle拓展支持的安装,搜了一下网上现有的几篇centos配置oracle的文章,其实都是有问题的.结合了相关搜索结果进行了整理,给出最完美的解决方案如下:

1. 下载oracle官方的rpm包 

http://download.oracle.com/otn/linux/instantclient/11203/oracle-instantclient11.2-sqlplus-11.2.0.3.0-1.x86_64.rpm

http://download.oracle.com/otn/linux/instantclient/11203/oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm

这两个下载地址都很恶心地被oracle墙在用户登录验证成功之后才能下载,所以你要去注册很恶心的oracleID(虽然是免费注册的.)直接wget来的将会是一个错误页面.

 

2.查看一下两个包的默认安装路径

rpm -qpl oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm

rpm -qpl oracle-instantclient11.2-sqlplus-11.2.0.3.0-1.x86_64.rpm

一般正常情况下,默认安装路径为:

oracle-instantclient11.2-sqlplus-11.2.0.3.0-1.x86_64.rpm:

/usr/bin/sqlplus64
/usr/lib/oracle/11.2/client64/bin/sqlplus
/usr/lib/oracle/11.2/client64/lib/glogin.sql
/usr/lib/oracle/11.2/client64/lib/libsqlplus.so
/usr/lib/oracle/11.2/client64/lib/libsqlplusic.so

 

oracle-instantclient11.2-basic-11.2.0.3.0-1.x86_64.rpm:

/usr/lib/oracle/11.2/client64/bin/adrci
/usr/lib/oracle/11.2/client64/bin/genezi
/usr/lib/oracle/11.2/client64/lib/libclntsh.so.11.1
/usr/lib/oracle/11.2/client64/lib/libnnz11.so
/usr/lib/oracle/11.2/client64/lib/libocci.so.11.1
/usr/lib/oracle/11.2/client64/lib/libociei.so
/usr/lib/oracle/11.2/client64/lib/libocijdbc11.so
/usr/lib/oracle/11.2/client64/lib/ojdbc5.jar
/usr/lib/oracle/11.2/client64/lib/ojdbc6.jar
/usr/lib/oracle/11.2/client64/lib/xstreams.jar

 

3.修改全局环境变量

nano /etc/profile
# Oracle InstantClient PATH by Daishengxiang 2013/04/06 2:56
export PATH=$PATH:/usr/lib/oracle/11.2/client64/bin
export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib/oracle/11.2/client64/lib
export ORACLE_HOME=/usr/lib/oracle/11.2
export TNS_ADMIN=/usr/lib/oracle/11.2/network/admin

 

4.创建配置文件

mkdir /usr/lib/oracle/11.2/network/admin

nano /usr/lib/oracle/11.2/network/admin/tnsnames.ora

 

其中tnsnames.ora的内容可以从oracle server那边直接拷贝过来,形式如同:

PRODB2 =
    (DESCRIPTION =
            (ADDRESS_LIST =
                    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.3.103.1)(PORT = 1521))
            )
            (CONNECT_DATA =
                    (SERVER=DEDICATED)
                    (SID = PRODB2)
            )
    )

 

最后,通过sqlplus测试连接oracle,通过连接.证明配置成功有效

 

Read More

使用php调用oracle数据库的几篇参考文章

经过和ci框架自带oci8 driver的多次挣扎,果断放弃了自带类(但是项目中有个恶心的牺牲点,这里就不恶心大家了..以后有空了我会回来改的….).找到几篇php调用oracle存储过程的参考文章,并且根据这几篇文章中提到的提示,成功解决了项目中的问题,特此马克一下文章地址,方便以后学习整理.

 

1. oracle中文官网的这篇文章范例还是很详尽的,但是部分oci_方法已经在php5之后做了些许修改,因此建议再查找php的官方手册进行对比学习

http://www.oracle.com/technetwork/cn/articles/fuecks-sps-082839-zhs.html

 

2.Call Oracle (oci8) store procedure from Codeigniter 国外被墙blog里面的一篇讲解通过pdo_oci8去使用oracle存储过程的详细说明

http://manasbala.wordpress.com/2012/03/20/call-oracle-oci8-store-procedure-from-codeigniter/

 

3.php官方权威手册的oci8操作指南,不得不说,这块冷门资料官方的example还是依旧非常详细.

http://www.php.net/manual/en/ref.oci8.php

 

Read More