当通过PHP5运行Apache没有找到OCI8功能 [英] OCI8 functions not found when run by apache with php5

查看:177
本文介绍了当通过PHP5运行Apache没有找到OCI8功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想建立一个服务器在我的数据库类的项目。我会在PHP在写项目,通过Apache部署它,并连接到远程Oracle服务器。我在与Oracle连接部分的麻烦。我有Oracle的instantclient 10.2版安装OCI8模块。我认为这是工作,因为当我跑下面的程序从控制台我得到了正确的输出。结果
程序:

I'm trying to set up a server for a project in my databases class. I'll be writing the project in php, deploying it via apache, and connecting to a remote oracle server. I'm having trouble with the oracle connection portion. I have the OCI8 module installed with oracle's instantclient version 10.2. I thought it was working because when I ran the following program from the console I got the right output.
Program:

<?php
$conn = oci_connect("asdf", "asdf", "asdf");
if (!$conn) {
   die("connection error\n");
}

$stid = oci_parse($conn, 'SELECT * FROM PARTS');
if (!$stid) {
   die("statement parsing error\n");
}

$r = oci_execute($stid);
if (!$r) {
   die("execution error\n");
}

print "<table border='1'\n";
while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
   print "<tr>\n";
   foreach ($row as $item) {
      print "\t<td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : "&nbsp;") . "</td>\n";
   }
   print "</tr>\n";
}
print "</table>\n";

oci_free_statement($stid);
oci_close($conn);
?>

结果:结果
    &LT;表边框='1'&GT; 结果
    &LT; TR&GT; 结果
    &LT; TD&GT; 1 LT; / TD&GT; 结果
    &LT; TD&GT;扳手及LT; / TD&GT; 结果
    &LT; TD&GT;银&LT; / TD&GT; 结果
    &LT; / TR&GT; 结果
    &LT; TR&GT; 结果
    &LT; TD&GT; 2'; / TD&GT; 结果
    &LT; TD&GT;锤&LT; / TD&GT; 结果
    &LT; TD&GT;布朗和LT; / TD&GT; 结果
    &LT; / TR&GT; 结果
    &LT; /表&gt;

Result:
<table border='1'>
<tr>
<td>1</td>
<td>wrench</td>
<td>silver</td>
</tr>
<tr>
<td>2</td>
<td>hammer</td>
<td>brown</td>
</tr>
</table>

因此​​,我认为一切都很好。但是,当我访问同一个PHP页面在浏览器中,我得到了以下错误消息:结果
致命错误:调用未定义的函数oci_connect()在/home/eric/apache2/htdocs/realestate/basicQuery.php第2行结果
我认为,可能意味着越来越被用于命令行和Apache的两个不同版本的PHP,所以我跑的phpinfo();对彼此而言。但他们都回来了相同的PHP信息(PHP版本5.2.10-2ubuntu6.4)。他们正在使用不同的php.ini文件(/etc/php5/apache2/php.ini和/etc/php5/cli/php.ini),但它们都是完全相同。我不知道还有什么地方去寻找任何可能在一个环境与其他的不同。结果
感谢您的帮助!

So I thought everything was fine. But when I visit the same php page in a browser I get the following error message:
Fatal error: Call to undefined function oci_connect() in /home/eric/apache2/htdocs/realestate/basicQuery.php on line 2
I thought that might mean that two different versions of php were getting used for the command line and in apache, so I ran phpinfo(); for both. But they both came back with the same php info (PHP Version 5.2.10-2ubuntu6.4). They are using different php.ini files (/etc/php5/apache2/php.ini and /etc/php5/cli/php.ini), but they both are exactly the same. I don't know where else to look for anything that might be different in one environment versus the other.
Thanks for any help!

推荐答案

你有没有在 OCI8 扩展安装在您的系统?检查,如果它不是,那么安装它跟随下面的链接?

Did you have the oci8 extension installed in your system? Check that if it is not then to install it follow the below links?

有关的理解是指这一点。
<一href=\"http://stackoverflow.com/questions/34350060/installing-oci8-extension-in-linux-for-php/34351036#34351036\">Installing在linux下的PHP OCI8扩展?

For understanding refer this. Installing oci8 extension in linux for php?

有关明确指示安装参考此链接。
http://www.oracle.com/technetwork/articles/dsl/technote-php-instant-12c-2088811.html

For clear instruction to install refer this link. http://www.oracle.com/technetwork/articles/dsl/technote-php-instant-12c-2088811.html

检查您的php.ini文件是否已设置以下的东西。

Check your php.ini file whether you have the following things set.

extension=oci.so

extension_dir="Your path where .so files are present"

安装之后重启apache 。让我知道如果这可以帮助你。

After the installation you should restart apache. Let me know if this helps you.

这篇关于当通过PHP5运行Apache没有找到OCI8功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆