简体   繁体   English

MAMP:PHP -m 显示 oci8 已启用,但不在 phpinfo 中

[英]MAMP: PHP -m shows oci8 enabled, but not in phpinfo

My objective is to connect to Oracle database through OCI8 which is available through:我的目标是通过 OCI8 连接到 Oracle 数据库,OCI8 可通过以下方式获得:

pecl install oci8-2.0.11

To achieve that, I've been following various tutorials on the Net to make it work.为了实现这一点,我一直在学习网络上的各种教程以使其工作。

I followed the following tutorials:我遵循了以下教程:

  1. http://www.baldwhiteguy.co.nz/technical/index_files/mac-osx-oracle-instantclient.html http://www.baldwhiteguy.co.nz/technical/index_files/mac-osx-oracle-instantclient.html
  2. http://www.enavigo.com/2012/01/04/enabling-oracle-oci8-php-extension-on-os-x-snow-leopard/ http://www.enavigo.com/2012/01/04/enabling-oracle-oci8-php-extension-on-os-x-snow-leopard/
  3. http://tomytree22.blogspot.my/2014/09/oci-driver-installation-on-mac.html http://tomytree22.blogspot.my/2014/09/oci-driver-installation-on-mac.html

These tutorials are enough to run SQL Plus.这些教程足以运行 SQL Plus。 I am also able to successfully run pecl install oci-8.20.11 and get this output:我还能够成功运行 pecl install oci-8.20.11 并获得以下输出:

You should add "extension=oci8.so" to php.ini

In the 3rd tutorial I listed above, I followed all except under instantclient library has some hardcoded paths we need to take care of:在我上面列出的第三个教程中,除了在Instantclient 库下有一些我们需要处理的硬编码路径之外,我都遵循了:

When I run php -m, I can see the oci8 is there, but I don't see it inside my phpinfo.当我运行 php -m 时,我可以看到 oci8 在那里,但我在 phpinfo.php 中没有看到它。 What did I do wrong?我做错了什么?

When I tried to connect to the Oracle database anyway, I am stuck with this:无论如何,当我尝试连接到 Oracle 数据库时,我遇到了以下问题:

Fatal error: Call to undefined function oci_connect()

I hope someone here can help me.我希望这里有人可以帮助我。 I'm using El Capitan.我正在使用 El Capitan。

So I fixed it.所以我修好了。 Here's how I get to the solution.这是我如何解决的。

I looked into my php log (make sure you enabled your PHP to log all errors! Just go to your error_log path to look for your error) and I found this:我查看了我的 php 日志(确保您已启用 PHP 来记录所有错误!只需转到您的 error_log 路径以查找您的错误),我发现了这一点:

[06-May-2016 09:48:12 Europe/Berlin] PHP Warning: PHP Startup: Unable to load dynamic library '/Applications/MAMP/bin/php/php5.6.10/lib/php/extensions/no-debug-non-zts-20131226/oci8.so' - dlopen(/Applications/MAMP/bin/php/php5.6.10/lib/php/extensions/no-debug-non-zts-20131226/oci8.so, 9): Library not loaded: /ade/b/3071542110/oracle/rdbms/lib/libclntsh.dylib.11.1 [06-May-2016 09:48:12 Europe/Berlin] PHP 警告:PHP 启动:无法加载动态库 '/Applications/MAMP/bin/php/php5.6.10/lib/php/extensions/no-debug- non-zts-20131226/oci8.so' - dlopen(/Applications/MAMP/bin/php/php5.6.10/lib/php/extensions/no-debug-non-zts-20131226/oci8.so, 9): 库未加载:/ade/b/3071542110/oracle/rdbms/lib/libclntsh.dylib.11.1

and

[09-May-2016 04:53:51 Europe/Berlin] PHP Warning: PHP Startup: Unable to load dynamic library '/Applications/MAMP/bin/php/php5.6.10/lib/php/extensions/no-debug-non-zts-20131226/oci8.so' - dlopen(/Applications/MAMP/bin/php/php5.6.10/lib/php/extensions/no-debug-non-zts-20131226/oci8.so, 9): Library not loaded: /ade/dosulliv_ldapmac/oracle/ldap/lib/libnnz11.dylib [09-May-2016 04:53:51 Europe/Berlin] PHP 警告:PHP 启动:无法加载动态库 '/Applications/MAMP/bin/php/php5.6.10/lib/php/extensions/no-debug- non-zts-20131226/oci8.so' - dlopen(/Applications/MAMP/bin/php/php5.6.10/lib/php/extensions/no-debug-non-zts-20131226/oci8.so, 9): 库未加载:/ade/dosulliv_ldapmac/oracle/ldap/lib/libnnz11.dylib

So oci8.so is not loaded because there are two libraries that are not loaded.所以oci8.so没有加载是因为有两个库没有加载。

Here's how I fixed it:这是我修复它的方法:

And that means, the one that I skipped which is instantclient library has some hardcoded paths we need to take care of: is the one I needed.这意味着,我跳过的那个Instantclient 库有一些我们需要处理的硬编码路径:就是我需要的那个。 So I run these commands (copy pasted from the tutorial):所以我运行这些命令(从教程中复制粘贴):

sudo mkdir -p /ade/b/3071542110/oracle/rdbms/lib/
sudo ln -sf /Applications/MAMP/bin/php/php5.5.10/lib/php/instantclient_11_2/libclntsh.dylib.11.1 /ade/b/3071542110/oracle/rdbms/lib/libclntsh.dylib.11.1
sudo mkdir -p /ade/dosulliv_ldapmac/oracle/ldap/lib/
sudo ln -sf /Applications/MAMP/bin/php/php5.5.10/lib/php/instantclient_11_2/libnnz11.dylib /ade/dosulliv_ldapmac/oracle/ldap/lib/libnnz11.dylib

and then I restarted my MAMP.然后我重新启动了我的 MAMP。 And now I got what I want, which is OCI8.现在我得到了我想要的东西,那就是 OCI8。 Now the info is available on my PHPInfo.现在信息在我的 PHPInfo 上可用。

我的 PHPInfo OCI8

Hope this will help the rest of guys who are embarking the same path of setting up OCI to connect to Oracle on MAMP.希望这将有助于其他正在走相同路径设置 OCI 以连接到 MAMP 上的 Oracle 的人。

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

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