php7.2如何连接oracle数据库(oracle,php,编程语言)

时间:2024-05-02 09:23:29 作者 : 石家庄SEO 分类 : 编程语言
  • TAG :

php7.2如何连接oracle数据库

一:下载文件

1 :oracle官网下载:

下载文件(看准了文件名):

oracle-instantclient19.8-basic-19.8.0.0.0-1.x86_64.rpmoracle-instantclient19.8-devel-19.8.0.0.0-1.x86_64.rpm复制代码

2 :PHP官网下载地址:

https://www.php.net/manual/zh/oci8.installation.php

PHP-OCI8插件

下载命令:

wgethttp://pecl.php.net/get/oci8-2.2.0.tgz

建议将以上三个文件放入/opt目录下,当然,具体放哪是你的自由。能找到就行。

二:安装

1 :安装oracle插件

rpm-ivhoracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpmrpm-ivhoracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm

可能会报错:

ImportError: libaio.so.1: cannot open shared object file: No such file or directory”

报错原因上边已经给出,缺少libiao插件,解决方法:

yuminstalllibaio

2 :安装OCI8插件

(1):解压tar包:

tar-zxfoci8-2.2.0.tgz

(2):进入解压目录

cdoci8-2.2.0

(3):运行一下命令:

phpize

运行的时候可能会出现一下错误:Can't find PHP headers in /usr/include/php The php-devel package is required for use

解决方案

yuminstallphp72w-devel#注意一下,这条命令取决你安装的PHP版本,我这个命令并不适用所有人

(4):使用$ORACLE_HOME或Instant Client配置软件包

./configure--with-oci8=shared,instantclient,/usr/lib/oracle/<version>/client/lib

./configure-with-oci8=shared,$ORACLE_HOME

(5):执行编译安装:

makeinstall

这里可能会报错:

make: *** No rule to make target build', needed by default'. Stop.

解决方案:

1:安装如下配置:

yum-yinstallmakezlib-develgcc-c++libtoolopensslopenssl-devel

2: 重新 configure

./configure

3: 编译

make&&makeinstall

(6):配置php.ini

我们在PHP的配置文件php.ini中加上

extension=oci8.so

重启PHP

systemctlrestartphp-fpm

重启web服务器(nginx、apache等)。

systemctlrestartnginx

查看PHPinfo();如下图所示:

php7.2如何连接oracle数据库

然后,你就可以在你的PHP框架中配置多个数据库链接了。

 </div> <div class="zixun-tj-product adv-bottom"></div> </div> </div> <div class="prve-next-news">
本文:php7.2如何连接oracle数据库的详细内容,希望对您有所帮助,信息来源于网络。
上一篇:vue中的webpack怎么安装下一篇:

6 人围观 / 0 条评论 ↓快速评论↓

(必须)

(必须,保密)

阿狸1 阿狸2 阿狸3 阿狸4 阿狸5 阿狸6 阿狸7 阿狸8 阿狸9 阿狸10 阿狸11 阿狸12 阿狸13 阿狸14 阿狸15 阿狸16 阿狸17 阿狸18