编辑
如果您已经安装了 php(例如来自存储库),您只能从 PHP 源编译 PDO_OCI(您需要安装 Instantclient)
在 pdo_oci 文件夹中,运行以下命令:
$ phpize
$ ./configure --with-pdo-oci=instantclient,/usr,12.1
$ make && make install
$ echo "extension=pdo_oci.so" > /etc/php.d/pdo_oci.ini
$ service httpd restart
此方法只会在PHP扩展文件夹中创建一个pdo_oci.so,不需要重新编译整个PHP。您可以使用 PHP 的存储库版本来执行此操作,也可以使用 PHP 源代码中 ext 文件夹中的任何扩展来执行此操作。
首先,对不起我的英语不好。
我有同样的问题,但我已经可以解决了。
如消息所述,此 PECL 扩展已被弃用。您需要使用 PHP 源代码中包含的 PDO_OCI 从源代码编译 PHP。
我在 CentOS 6.6 中采用了这种方式,并安装了 MySQL、Apache 和 InstantClient:
像这样安装依赖项
curl-devel
freetype-devel
libc-client
libc-client-devel
libjpeg-devel
libmcrypt-devel
libpng-devel
libtool-ltdl-devel
libxml2-devel
libXpm-devel
libc-client
libc-client-devel
libmcrypt-devel
libpng-devel
db4-devel
...And other prompted dependencies in the ./configure
(always install the *-devel package too)
下载 PHP 源代码
$ wget http://ar2.php.net/get/php-5.6.10.tar.gz/from/this/mirror
解压下载的文件并切换到文件夹
$ tar -xzf php-5.6.10.tar.gz
$ cd php-5.6.10
使用所需参数执行 configure 命令(我的示例如下)
./configure \
--prefix=/usr \
--sysconfdir=/etc \
--localstatedir=/var \
--datadir=/usr/share/php \
--mandir=/usr/share/man \
--with-config-file-path=/etc \
--with-config-file-scan-dir=/etc/php.d \
--with-zlib \
--enable-bcmath \
--with-bz2 \
--enable-calendar \
--with-gdbm \
--with-gmp \
--enable-ftp \
--with-gettext \
--enable-mbstring \
--with-readline \
--with-apxs2 \
--with-pdo-oci=instantclient,/usr,12.1 \
--enable-dba=shared \
--with-pdo-mysql --with-mysql-sock=/var/mysql/mysql.sock \
--with-pdo-pgsql \
--with-mcrypt \
--with-mhash \
--with-curl \
--with-gd \
--enable-gd-native-ttf \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-zlib-dir=/usr \
--with-xpm-dir=/usr \
--with-vpx-dir=/usr \
--with-freetype-dir=/usr \
--with-t1lib=/usr \
--with-libxml-dir=/usr \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--enable-soap \
--with-xmlrpc \
--with-xsl \
--with-tidy=/usr \
--enable-pcntl \
--enable-sysvshm \
--enable-sysvmsg \
--enable-shmop
如果您在运行此命令时看到任何错误,则可能是缺少某些依赖项(可能是我没有提到的依赖项)。
运行配置命令后没有错误
$ make && make install
此时,PHP 已经安装完毕。
要进行认证,请使用以下命令:
$ php -v
但是在完成之前,我们需要做一些调整……
将php.ini复制到正确的目录
### If you're on a development server
$ cp php.ini-development /etc/php.ini
### If you're on a production server
$ cp php.ini-production /etc/php.ini
打开 Apache 配置文件进行编辑
$ vi /etc/httpd/conf/httpd.conf
添加以下行以便 Apache 解释 PHP(如果已经有则忽略)
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
重启 Apache
$ service httpd restart