Heim  >  Artikel  >  Datenbank  >  Linux下使用PHP远程连接Oracle

Linux下使用PHP远程连接Oracle

WBOY
WBOYOriginal
2016-06-07 17:35:39959Durchsuche

PHP远程连接Oracle需要OCI包,这个包由oracle提供,可以直接安装Oracle的InstantClient来得到这个包

PHP远程连接Oracle需要OCI包,这个包由oracle提供,可以直接安装Oracle的InstantClient来得到这个包
下载地址

安装很简单
rpm -Uvh oracle-instantclient-basic-10.2.0.3-1.i386.rpm
rpm -Uvh oracle-instantclient-devel-10.2.0.3-1.i386.rpm

安装完成后,可以在/usr/lib/oracle 看到安装的库文件

之后需要重新编译php,加上--with-oci8=share,instantclient,/usr/lib/oracle/10.2.0.3/client/lib参数,如下:
./configure --with-mysql --with-apxs2=/usr/local/apache2/bin/apxs--with-oci8=share,instantclient,/usr/lib/oracle/10.2.0.3/client/lib

测试代码:

$conn = OCILogon('username','password','192.168.1.2/test');
if (!$conn) {
$e = oci_error();
print htmlentities($e['message']);
exit;
}
else
{
echo "Successfully connected to Oracle!\n";
        ocilogoff($conn);
}
?>

一些相关链接:

还有就是php中oci的编译参数,可以看php原代码目录中ext/oci8的README,,里面有解释。

linux

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:MySQL数据库维护比较Nächster Artikel:Ubuntu 安装MySQL和简单操作