繁体   English   中英

在 PHP7 上安装 PDO_OCI

[英]Install PDO_OCI on PHP7

他,

几天以来,我尝试在新服务器上的 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_64 PHP PHP 版本 7.0.4-1~dotdeb+8.1 PDO 驱动程序 mysql启用 OCI8 支持(有效)。

我已阅读 PDO_OCI 包含在 PHP7 https://github.com/php/php-src/tree/PHP-7.0.7/ext/pdo_oci但如何激活它?

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

有人有解决方案吗?

问候

下载 PHP 的源文件(从https://www.php.net/downloads获取 URL,例如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

最后,创建并链接文件:

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)尝试第三方驱动程序

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM