首页 > CentOS > linux下,给php增加oci8模块
2014
11-19

linux下,给php增加oci8模块

每次安装oci8 总是出现各种各样的问题. 所以在这里做一个笔记,方便自己安装,也方便各位需要的朋友参考使用.

闲话少说 直接操作

 

1. 根据实际情况选择版本,下载oracle客户端压缩包和sdk压缩包
http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html
以下为 10.0.2 为例

2. 将client和sdk解压到同一个目录并放到操作系统的一个指定目录 比如 /soft/instantclient_10_2

3. 执行如下命令,将oracle环境变量加入到 profile

cat >>/etc/profile<<EOF
#_php_oci_instantclient
export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss'
export PATH=\$PATH:/soft/instantclient_10_2
export TNS_ADMIN=/soft/instantclient_10_2
export LD_LIBRARY_PATH=/soft/instantclient_10_2
export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"
export ORACLE_HOME=/soft/instantclient_10_2
EOF

4. 执行如下命令 ,修改 oracle_client so文件权限,修改上下文安全

chcon -t texrel_shlib_t /data/soft/instantclient_10_2/*.so
chcon -t texrel_shlib_t /data/soft/instantclient_10_2/*.so.*

5. 读取环境变量信息

source /etc/profile

6. 下载 oci8的压缩包 并进行编译
http://pecl.php.net/package/oci8
# 指定php变量 或者在with-php-config 位置替换变量,指定 php-config目录
PHP_DIR=php的安装目录

tar zxvf oci8-2.0.8.tar.gz
cd oci8-2.0.8
phpize
./configure \
--with-php-config=${PHP_DIR:?NULL}/bin/php-config \
--with-oci8=shared,instantclient,${ORACLE_HOME:?NULL}

make
make install

7. 修改 php.ini文件 增加
extension = “oci8.so”

8. 根据实际情况, 重启 php 或者 apache

最后编辑:
作者:王, 帅
这个作者貌似有点懒,什么都没有留下。

留下一个回复

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据