在PHP7上安装PDO_OCI


Install PDO_OCI on PHP7

He,

几天后,我尝试在新服务器上的PHP7上安装PDO_OCI。我曾经在其他服务器PDO_OCI上,但在PHP 5.4上,一切都很好,这个版本没有问题。

我收到消息:

:/home/pear/download/PDO_OCI-1.0# make
/bin/bash /home/pear/download/PDO_OCI-1.0/libtool --mode=compile cc -I -I. 
-I/home/pear/download/PDO_OCI-1.0 -DPHP_ATOM_INC 
-I/home/pear/download/PDO_OCI-1.0/include 
-I/home/pear/download/PDO_OCI-1.0/main 
-I/home/pear/download/PDO_OCI-1.0 
-I/usr/include/php/20151012 
-I/usr/include/php/20151012/main 
-I/usr/include/php/20151012/TSRM 
-I/usr/include/php/20151012/Zend 
-I/usr/include/php/20151012/ext 
-I/usr/include/php/20151012/ext/date/lib 
-I/usr/lib/oracle/instantclient/include/oracle/12.1/client  -DHAVE_CONFIG_H  -g -O2   -c 
/home/pear/download/PDO_OCI-1.0/oci_driver.c -o oci_driver.lo
libtool: compile:  cc -I -I. 
-I/home/pear/download/PDO_OCI-1.0 -DPHP_ATOM_INC 
-I/home/pear/download/PDO_OCI-1.0/include 
-I/home/pear/download/PDO_OCI-1.0/main 
-I/home/pear/download/PDO_OCI-1.0 
-I/usr/include/php/20151012 
-I/usr/include/php/20151012/main 
-I/usr/include/php/20151012/TSRM 
-I/usr/include/php/20151012/Zend 
-I/usr/include/php/20151012/ext 
-I/usr/include/php/20151012/ext/date/lib 
-I/usr/lib/oracle/instantclient/include/oracle/12.1/client -DHAVE_CONFIG_H -g -O2 -c 
/home/pear/download/PDO_OCI-1.0/oci_driver.c  -fPIC -DPIC -o .libs/oci_driver.o
/home/pear/download/PDO_OCI-1.0/oci_driver.c: In function 'pdo_oci_fetch_error_func':
/home/pear/download/PDO_OCI-1.0/oci_driver.c:51:3: error: 
too many arguments to function 'add_next_index_string' add_next_index_string(info, einfo->errmsg, 1);
In file included from /usr/include/php/20151012/main/php.h:39:0,
                 from /home/pear/download/PDO_OCI-1.0/oci_driver.c:25:
/usr/include/php/20151012/Zend/zend_API.h:432:14: note: declared here
 ZEND_API int add_next_index_string(zval *arg, const char *str);
              ^
/home/pear/download/PDO_OCI-1.0/oci_driver.c: In function 'oci_handle_preparer':
/home/pear/download/PDO_OCI-1.0/oci_driver.c:238:59: warning: passing argument 5 of 'pdo_parse_params' from incompatible pointer type
  ret = pdo_parse_params(stmt, (char*)sql, sql_len, &nsql, &nsql_len TSRMLS_CC);
                                                       ^
In file included from /home/pear/download/PDO_OCI-1.0/oci_driver.c:29:0:
/usr/include/php/20151012/ext/pdo/php_pdo_driver.h:678:13: note: expected 'size_t *' but argument is of type 'int *'
 PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, size_t inquery_len,
         ^
/home/pear/download/PDO_OCI-1.0/oci_driver.c: At top level:
/home/pear/download/PDO_OCI-1.0/oci_driver.c:411:2: warning: initialization from incompatible pointer type
  oci_handle_preparer,
 ^
/home/pear/download/PDO_OCI-1.0/oci_driver.c:411:2: warning: (near initialization for 'oci_methods.preparer')
/home/pear/download/PDO_OCI-1.0/oci_driver.c:412:2: warning: initialization from incompatible pointer type
  oci_handle_doer,
  ^
/home/pear/download/PDO_OCI-1.0/oci_driver.c:412:2: warning: (near initialization for 'oci_methods.doer')
/home/pear/download/PDO_OCI-1.0/oci_driver.c:413:2: warning: initialization from incompatible pointer type
  oci_handle_quoter,
  ^
/home/pear/download/PDO_OCI-1.0/oci_driver.c:413:2: warning: (near initialization for 'oci_methods.quoter')
Makefile:198: recipe for target 'oci_driver.lo' failed
make: *** [oci_driver.lo] Error 1

我的配置:Linux服务器系统Linux 3.16.0-4-amd64#1 SMP Debian 3.16.7-ckt20-1+deb8u4(2016-02-29)x86_64PHP PHP版本7.0.4-1~dotdeb+8.1PDO驱动程序mysqlOCI8支持已启用(正在工作)。

我已经阅读了PHP7中包含的PDO_OCIhttps://github.com/php/php-src/tree/PHP-7.0.7/ext/pdo_oci但是如何激活它呢?

我的PHP 5.4代码在此服务器PHP7上不起作用。

有人有解决方案吗?

问候

下载PHP的源文件(从https://www.php.net/downloads,例如。https://www.php.net/distributions/php-7.4.16.tar.bz2):

PHP_VERSION=7.3.27 # Set to your PHP version
cd /tmp
sudo apt-get install php-dev -y
wget https://www.php.net/distributions/php-${PHP_VERSION}.tar.gz
tar xvfj php-${PHP_VERSION}.tar.bz2
rm php-${PHP_VERSION}.tar.bz2

pdo_oci复制到/tmp:

cp -r /tmp/php-${PHP_VERSION}/ext/pdo_oci /tmp
cd /tmp/pdo_oci

构建插件:

sudo phpize
sudo ./configure --enable-option-checking=fatal # Optionally add more parameters
sudo make
sudo make install

Finall,创建和链接文件:

sudo echo "extension=pdo_oci.so" > /etc/php/7.3/mods-available/pdo_oci.ini
sudo ln -s /etc/php/7.3/mods-available/pdo_oci.ini /etc/php/7.3/apache2/conf.d/20-pdo_oci.ini

重新启动apache2

此扩展已被放弃,不会编译。为什么?PHP的API在版本7中发生了重大变化;您看到的错误表明内部函数签名已经更改:

/home/pear/download/PDO_OCI-1.0/oci_driver.c: In function 'pdo_oci_fetch_error_func':
/home/pear/download/PDO_OCI-1.0/oci_driver.c:51:3: error: 
too many arguments to function 'add_next_index_string' add_next_index_string(info, einfo->errmsg, 1);

如何修复这个问题取决于你如何安装PHP。我希望你自己编译它,因为你对扩展也是这样做的。如果是这样,只需使用--with-pdo-oci=DIR重新编译即可,其中DIR是Oracle主目录。

如果您是通过apt从软件包安装的,那么您有几个选择。1) 看看你是否可以用同样的方式获得PDO-OCI驱动程序(看起来没有。)2)删除你的包,从源代码开始做所有事情。3) 请尝试第三方驱动程序。