下载oracle相关的库文件
链接:https://pan.baidu.com/s/1PhsG37rJ7mXSZ97UGivMzg 密码:uwni
下载完成后:
oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm
oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm
oracle-instantclient12.1-sqlplus-12.1.0.2.0-1.x86_64.rpm
开始安装
rpm -ivh oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm
rpm -ivh oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm
rpm -ivh oracle-instantclient12.1-sqlplus-12.1.0.2.0-1.x86_64.rpm
echo "/usr/lib/oracle/12.1/client64/lib" > /etc/ld.so.conf.d/oracle_client.conf
/sbin/ldconfig
下载oci8 php扩展
下载地址 : http://pecl.php.net/package/oci8
> PHP5.6安装的是 oci8-1.4.x
> php7安装的是 : oci8-2.0.x
安装扩展
tar -zxvf oci8-2.1.0.tgz
cd oci8-2.1.0
/usr/local/php/bin/phpize
./configure --with-oci8=shared,instantclient,/usr/lib/oracle/12.1/client64/lib --with-php-config=/usr/local/php/bin/php-config
make && make install
修改配置 php.ini
extension=oci8.so
测试
<?php
$conn = oci_connect('用户名', '密码', '远程数据库名(//192.168.1.157/orcl)');
if (!$conn) {
$e = oci_error();
print htmlentities($e['message']);
exit;
}else {
echo "连接oracle成功!";
}
?>