基础环境
安装BT宝塔
网址:https://www.bt.cn/download/linux.html
安装ORACLE客户端
下载地址:
https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html
安装包:
oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm
oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm
PS: 前两个都必须安装,devel版本就是SDK
安装命令:
rpm -ivh oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
rpm -ivh oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm
rpm -ivh oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm
参考命令:
rpm -qa | grep oracle // 查看oracle是否安装
rpm -qa // 查看所有已安装的人rpm包
rpm -e oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm // 卸载已安装的rpm包
rpm -ivh --force oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm // 强制安装rpm包
添加环境变量:
vi /etc/profile
export ORACLE_HOME=/usr/lib/oracle/11.2/client64/
export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64:$LD_LIBRARY_PATH
export NLS_LANG="AMERICAN_AMERICA.AL32UTF8"
source /etc/profile
建立软连接:
64位系统需要创建32位的软链接(这里可能是一个遗留bug,不然后面编译会出问题)
ln -s /usr/lib/oracle/11.2/client64 /usr/lib/oracle/11.2/client
ln -s /usr/include/oracle/11.2/client64 /usr/include/oracle/11.2/client
ln -s /usr/include/oracle/11.2 /usr/include/oracle/10.2.0.1
ln -s /usr/lib/oracle/11.2 /usr/lib/oracle/10.2.0.1
安装php 的 oci8扩展
扩展地址:
https://pecl.php.net/package/oci8
点击 “Version” 版本,进去详情页:
使用 “pecl” 命令进行安装:
pecl install oci8-2.2.0
安装过程中添加参数:instantclient,/usr/lib/oracle/11.2/client/lib
注意事项:
使用安装php扩展包pecl命令是出现ERROR: failed to run `phpize‘
问题原因:php配置文件 php.ini 中将“popen”函数禁用了
解决方法:打开 php.ini 文件,将禁用函数“popen”删除。