php7.2如何连接oracle数据库
导读:本文共2027字符,通常情况下阅读需要7分钟。同时您也可以点击右侧朗读,来听本文内容。按键盘←(左) →(右) 方向键可以翻页。
摘要: 一:下载文件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/ma... ...
目录
(为您整理了一些要点),点击可以直达。一:下载文件
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();
如下图所示:
然后,你就可以在你的PHP框架中配置多个数据库链接了。
</div> <div class="zixun-tj-product adv-bottom"></div> </div> </div> <div class="prve-next-news">
php7.2如何连接oracle数据库的详细内容,希望对您有所帮助,信息来源于网络。