debian安装orcale支持库
官方说明
https://pecl.php.net/package/oci8
安装基础环境
apt-get install libaio1 apt-get install alien
安装21版本库
其他版本详见:https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html 版本兼容性详见(需要登录):https://support.oracle.com/epmos/faces/DocumentDisplay?id=207303.1
下载
wget https://download.oracle.com/otn_software/linux/instantclient/2116000/oracle-instantclient-basic-21.16.0.0.0-1.x86_64.rpm wget https://download.oracle.com/otn_software/linux/instantclient/2116000/oracle-instantclient-sqlplus-21.16.0.0.0-1.x86_64.rpm wget https://download.oracle.com/otn_software/linux/instantclient/2116000/oracle-instantclient-devel-21.16.0.0.0-1.x86_64.rpm wget https://download.oracle.com/otn_software/linux/instantclient/2116000/oracle-instantclient-jdbc-21.16.0.0.0-1.x86_64.rpm wget https://download.oracle.com/otn_software/linux/instantclient/2116000/oracle-instantclient-odbc-21.16.0.0.0-1.x86_64.rpm
安装
alien -i oracle-instantclient-basic-21.16.0.0.0-1.x86_64.rpm alien -i oracle-instantclient-sqlplus-21.16.0.0.0-1.x86_64.rpm alien -i oracle-instantclient-devel-21.16.0.0.0-1.x86_64.rpm alien -i oracle-instantclient-jdbc-21.16.0.0.0-1.x86_64.rpm alien -i oracle-instantclient-odbc-21.16.0.0.0-1.x86_64.rpm
环境配置
在文件/etc/ld.so.conf
最后加入
nano /etc/ld.so.conf
在文件最后加入
/usr/lib/oracle/21/client64/lib
然后执行ldconfig
使配置生效。 执行sqlplus
来验证配置。
在/etc/profile
文件最后,加入
nano /etc/profile
在文件最后加入
export ORACLE_HOME=/usr/lib/oracle/21/client64 export ORACLE_BASE=/usr/lib/oracle/21 export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH export PATH=$ORACLE_HOME/bin:$PATH
保存退出后执行以下命令后使环境变量生效:
source /etc/profile
建立软连接
ln -s /usr/lib/oracle/21/client64 /usr/lib/oracle/21/client ln -s /usr/include/oracle/21/client64 /usr/include/oracle/21/client
PHP安装扩展
推荐使用pecl安装,详见:http://pear.php.net
pecl install oci8 pdo_oci
中途需要输入路径:instantclient,/usr/lib/oracle/21/client64/lib
修改php.ini文件,加入扩展。如果不知道php.ini在什么地方,可执行:php --ini
查看配置文件路径
extension=oci8.so extension=pdo_oci.so
可以通过
php -m | grep oci
验证是否成功