You are here

Linux下面的Drupal连接oracle配置文档

1, 先用一段代码测试一下:

       $conn = oci_connect('username', 'password', 'dbname');

if($conn) {

  //echo"连接oracle成功!";

  drupal_set_message('连接oracle成功!');

}else{

 // echo"连接oracle失败!";exit;

  drupal_set_message('连接oracle失败!');

}

 

报错:

The website encountered an unexpected error. Please try again later.
Error: Call to undefined function Drupal\mycustom\Controller\oci_connect() in Drupal\mycustom\Controller\MycustomController->testPage() (line 30 of modules/custom/mycustom/src/Controller/MycustomController.php).


参考文档:

https://www.cnblogs.com/xuzhengzong/p/9104700.html

 

第一步:

分别下载 oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm     oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm

放在/usr/packages/目录下,执行:

#  cd /usr/packages/

# rpm -ivh oracle-instantclient*

此时会生成/usr/lib/oracle/11.2/client64/lib/目录

  

2步:


二、修改/etc/ld.so.conf配置文件

追加以下内容 -- 上面生成文件的路径,没有64的写client/lib/

/usr/lib/oracle/11.2/client64/lib/

保存、退出,执行命令 # ldconfig

  

第3步:

三、安装oci8

 

下载地址:http://pecl.php.net/package/oci8

下载 oci-2.0.8.tgz

放在/usr/packages/目录下,依次执行:

 

tar -xvzf oci-2.0.8.tgz


 

 

Can't find PHP headers in /usr/include/php

The php-devel package is required for use of this command.

 

 

安装php-dev以及依赖Perl(tap::parser)

 

对应于:

rpm -ivh perl-Test-Harness-3.28-3.el7.noarch.rpm

 


 编辑php.ini

 

extension=oci8.so

 



Drupal版本: