在CentOS 6.7 64位安装PHP的PDO_OCI扩展 Installing PDO_OCI extension on CentOS 6.7 64bit
需求&背景
最近根据项目需求,要在php中远程连接Oracel 11g Express数据库,为了开发方便,决定采用pdo,也就是php的PDO_OCI扩展,但是php安装的时候并没有安装PDO_OCI扩展,所以现在需要新增一个php扩展。
解决方案
首先上google搜索了一下,找到一片文章:http://shiki.me/blog/installing-pdo_oci-and-oci8-php-extensions-on-centos-6-4-64bit/, 这篇文章讲的很详细,非常感谢作者!
我在这里再简略总结一下:
首先要安装Oracle数据库的InstantClient: 下载地址:http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html。根据自己的系统,选择合适的安装包,Basic和devel两个包都需要安装。因为我的服务器上并没有安装Oracle 11g Express数据库,所以需要安装, 如果服务器上已经装好了Oracle 11g Express数据库, 这一步应该是可以忽略的(仅仅是一个猜测,没有测试)
从pear下载PDO_OCI的源码包 (https://pecl.php.net/package/PDO_OCI), 选择1.0的stable版本即可, 可以使用wget直接下载到linux, 或者使用pecl命令(推荐):
$ pecl download PDO_OCI
$ tar -xvf PDO_OCI-1.0.tgz
$ cd PDO_OCI-1.0因为PDO_OCI这个扩展已经很久没有更新了,需要编辑config.m4这个文件以支持11g或者更高版本的数据库, 具体如下:
在第10行左右添加如下代码:
elif test -f $PDO_OCI_DIR/lib/libclntsh.$SHLIB_SUFFIX_NAME.11.2; then
PDO_OCI_VERSION=11.2在101行左右添加如下代码:
11.2)
PHP_ADD_LIBRARY(clntsh, , PDO_OCI_SHARED_LIBADD)
;;然后就是用phpize这个工具进行编译安装:
$ phpize
//如果系统提示没有找到这个命令,只需要安装php-devel即可
//$ yum install php-devel
$ ./configure --with-pdo-oci=instantclient,/usr,11.2
$ make
$ sudo make install我在运行 ./configure --with-pdo-oci=instantclient,/usr,11.2后得到一个错误: checking for oci.h... configure: error: I'm too dumb to figure out where the include dir is in your instant client install 意思是说, 没有找到instant client 的include 文件夹, 这是为什么呢?继续google, 这个问题不多见,我花了很多时间在这个问题上面。最后看到一片文章下的评论:
Changes for x86_64 November 10th 2010 at 09:11 am Some changes were required to get the configure to work on a 64 bit Redhat (Fedora 13) system.
We installed the 64 bit version of oracle-instantclient-{devel,basic}.
These installed in:
/usr/lib/oracle/11.2/client64
/usr/include/oracle/11.2/client64We created symlinks as follows:
/usr/lib/oracle/11.2/client -> /usr/lib/oracle/11.2/client64
/usr/include/oracle/11.2/client -> /usr/include/oracle/11.2/client64Then the "./configure --with-pdo-oci=instantclient,/usr,11.2" command worked fine!
The reason for the symlinks instead of changing the variables in the oracle.sh is that the build/configure scripts seem to be hard coded for "client" (not client64) in many places. It was easer to create 2 symlinks than to change all the code in every script/config file.
非常感谢这问网友。大概意思是在configure时查找的文件夹是/usr/lib/oracle/11.2/client 和/usr/include/oracle/11.2/client, 这两个文件夹位置的组成方式是:${prefix}/lib OR lib/oracle/${version}/client,而64bit 的Instant Client的安装目录都是client64,所以configure的时候找不到,解决这个问题只需要添加两个符号链接即可:
$ ln -s /usr/lib/oracle/11.2/client64 /usr/lib/oracle/11.2/client
$ ln -s /usr/include/oracle/11.2/client64 /usr/include/oracle/11.2/client添加好符号链接后,再次执行
$ ./configure --with-pdo-oci=instantclient,/usr,11.2
$ make
$ sudo make install执行成功, 没有报错。
make install 成功之后,在 /usr/lib64/php/modules/ 就会出现pdo_oci.so,然后在php的配置文件中激活pdo_oci扩展:
$ vi /etc/php.d/pdo_oci.ini
添加内容: extension=pdo_oci.so
重启apache就可以使用PDO_OCI扩展了。
如果您觉得阅读本文对您有帮助,欢迎转载本文,但是转载文章之后必须在文章页面明显位置保留此段声明,否则保留追究法律责任的权利。
作 者:blog.jpdou.top
原文链接:http://blog.jpdou.top/install-pdo_oci-extension-on-linux-64bit/
在CentOS 6.7 64位安装PHP的PDO_OCI扩展 Installing PDO_OCI extension on CentOS 6.7 64bit的更多相关文章
- CentOS 6.5 64位 安装Nginx, MySQL, PHP
此篇文章参考了一些网站找的教程,自己遇到了很多坑,写一下自己的安装全过程. 服务器是腾讯云的.安装了centos 6.5系统. 一. 安装Nginx 1.首先安装GCC,make,C++编译器 yum ...
- CentOS 6.5 64位 安装zabbix-2.2.0
安装环境: VM 10 + CentOS-6.5-x86_64-minimal 虚拟机网络是NAT方式, 动态IP Xshell登录到Centos操作 刚装的centos,啥都没有,先配一下yum 首 ...
- CentOS 6.4 64位 安装 jdk 6u45
准备: 1.下载历史版本jdk 地址: http://java.sun.com/products/archive/ 下载的版本 jdk-6u45-linux-x64-rpm.bin Linux x6 ...
- 阿里云服务器CentOS 5.7(64位)安装配置LAMP服务器(Apache+PHP5+MySQL)
一.快速安装Apache+PHP5+MySql ----------------------------------------------------- 补充:由于163的yum源上只有php5.1 ...
- CentOS 7.4 64位安装配置MySQL8.0
第一步:获取mysql YUM源 进入mysql官网获取RPM包下载地址 https://dev.mysql.com/downloads/repo/yum/ image.png 点击下载 im ...
- centos 6.3 64位安装php5.5及配置tengine
PHP 用到的工具包: yum install gd-devel libjpeg-devel libpng-devel freetype-devel libxml2-devel curl-devel ...
- CentOS 6.4 64位 安装 mysql 5.6.24
下载安装包 由于官网访问及版本选择下载不太方便,使用 suho 的源进行下载 http://mirrors.sohu.com/mysql/MySQL-5.6/ 下载如下三个安装包: MySQL-ser ...
- CentOS 7.0 64位 安装TFTP
1.安装tftp软件# yum -y install tftp*2.修改配置文件 # vi /etc/xinetd.d/tftp server_args = -s /tftpboot '加-cdisa ...
- CentOS 7.6 64位安装docker并设置开机启动
步骤如下 安装docker.docker-compose yum -y install docker-io docker-compose 启动docker service docker start 设 ...
随机推荐
- 51nod1674:区间的价值2(分治,利用&和|的收敛性)
lyk拥有一个区间. 它规定一个区间的价值为这个区间中所有数and起来的值与这个区间所有数or起来的值的乘积. 例如3个数2,3,6.它们and起来的值为2,or起来的值为7,这个区间对答案的贡献为2 ...
- SPOJ:Another Longest Increasing Subsequence Problem(CDQ分治求三维偏序)
Given a sequence of N pairs of integers, find the length of the longest increasing subsequence of it ...
- vmware 克隆linux虚拟机后的网卡修改方法
VMware虚拟机安装好CentOS6.5系统后,纯净的系统多克隆几份出来方便后期做试验.克隆步骤很简单,克隆后出现的问题是克隆后的网卡MAC地址和原系统MAC地址一样,在局域网内会有冲突,需要更改克 ...
- Vue 项目中添加全局过滤器以及全局混合mixin
可以在.vue文件中定义局部使用的过滤器 export default{ data(){ return [] }, filters:{ toUpperCase:function(value){ ret ...
- c/c++面试23-29
23 一般引用的用法 (1)代码 #include <iostream> #include <string> using namespace std; int main(int ...
- html和xml的区别
一.HTML HTML(HyperTextMark-upLanguage)即超文本标记语言,是WWW的描述语言. 二.XML XML即ExtentsibleMarkup Language(可扩展标记语 ...
- Srping MVC入门推荐
看了不少大牛们的博客,对Spring MVC心里还是一团迷雾. 看了<Spring in Action>(Spring实战),疑惑渐渐明朗. 特推荐此书.
- .NET Core 3.0之深入源码理解Configuration(三)
写在前面 上一篇文章讨论了文件型配置的基本内容,本篇内容讨论JSON型配置的实现方式,理解了这一种配置类型的实现方式,那么其他类型的配置实现方式基本可以触类旁通.看过了上一篇文章的朋友,应该看得出 ...
- 16-CoreData之多表关联(存储自定义数据模型)
多表关联 1.1-简介 什么是多表关联 在处理数据库的关系中,无非只有三种关系 一对一:一个老师只能在一个教室上课,不可能同时在两个教室上课 一对多:一个教室可以有多个学生,但一个学生只能在一个教室 ...
- 658. Find K Closest Elements
Given a sorted array, two integers k and x, find the k closest elements to x in the array. The resul ...