ITPub博客

首页 > IT职业 > IT职场 > PHP增加OCI8模块

PHP增加OCI8模块

IT职场 作者:qingcai 时间:2021-09-09 09:18:49 0 删除 编辑

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#_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

end

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2899/viewspace-2802059/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-08-19

  • 博文量
    71
  • 访问量
    681