根据我的理解以及以前的安装,要在centOs上使用php 5.6安装oci8,我需要完成以下步骤:
这就是我在供应文件中所做的。
installOracleInstantClient() {
# ===================================================================
# Install Oracle Support for PHP
# ===================================================================
if [ $(rpm -qa | grep -c 'oracle-instantclient') -eq 0 ]; then
printLog 'Installing Oracle Client'
yum --quiet -y install libaio
yum -y --nogpgcheck --quiet install /opt/packages/oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
yum -y --nogpgcheck --quiet install /opt/packages/oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm
cat > /etc/environment <<EOM
ORACLE_HOME="/usr/lib/oracle/11.2/client64"
LD_LIBRARY_PATH="/usr/lib/oracle/11.2/client64/lib"
EOM
cat > /etc/profile.d/oracle.sh <<EOM
export ORACLE_HOME=/usr/lib/oracle/11.2/client64
export PATH=$PATH:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export TNS_ADMIN=$ORACLE_HOME/network/admin
EOM
export ORACLE_HOME=/usr/lib/oracle/11.2/client64
export PATH=$PATH:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export TNS_ADMIN=$ORACLE_HOME/network/admin
mkdir -p /usr/lib/oracle/11.2/client64/network/admin -p
fi
}
installPHP() {
if [ $(rpm -qa | grep -c 'php') -eq 0 ]; then
printLog 'Installing PHP'
installGcc;
installEPEL;
installGit;
printLog 'Adding php5.6 repositories'
rpm -Uvh http://vault.centos.org/7.0.1406/extras/x86_64/Packages/epel-release-7-5.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
yum install yum-utils
printLog 'installing php packages'
yum --enablerepo=remi,remi-php56 install --quiet -y php php-common php-cli php-pear php-pdo php-devel php-ldap php-mbstring php-bcmath php-mysqlnd php-soap php-gd php-xml php-simplexml php-curl php-zip php-oci8 php-ldap php-zip php-fileinfo
# php-mssql php-sqlite php-mcrypt
printLog 'Installing OCI8 extension for PHP'
printf "instantclient,/usr/lib/oracle/11.2/client64" | pecl install oci8-2.0.12
# bits to add oci to php.ini
echo 'extension=oci8.so' >> /etc/php.ini
sudo sh -c "echo /usr/lib/oracle/11.2/client64 > /etc/ld.so.conf.d/oracle.conf"
sudo ldconfig
fi
}
installOracleInstantClient;
installPHP;
在计算机配置中,出现以下错误:
default: PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/oci8.so' - libclntsh.so.18.1: cannot open shared object file: No such file or directory in Unknown on line 0
default: PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/pdo_oci.so' - libclntsh.so.18.1: cannot open shared object file: No such file or directory in Unknown on line
0
与我一起进入机器并执行php -v
时相同。
执行ldd -r /usr/lib64/php/modules/oci8.so
返回一堆Undefined symbol
错误和预期的libclntsh.so.18.1 => not found
行。
此外,php -i
不会返回正确安装oci8后通常显示的OCI8块。
关于我在做什么错的任何想法吗?
答案 0 :(得分:1)
使用“ remi-php56”存储库,您无需从源代码构建扩展,所有内容都在存储库中;)
(pecl命令将仅安装oci8扩展名,而不安装PDO驱动程序)
使用Oracle Client 18c构建软件包,并允许连接到服务器版本18c,12.2、12.1和11.2。
答案 1 :(得分:0)
您需要安装Oracle客户端18c。我试图安装11.2 oracle客户端并建立符号链接,但这不起作用。
more /etc/ld.so.conf.d/oracle.conf
/u01/app/oracle/product/18.5.0
# ldd /usr/lib64/php/modules/oci8.so
linux-vdso.so.1 => (0x00007ffe2b368000)
libclntsh.so.18.1 => /u01/app/oracle/product/18.5.0/libclntsh.so.18.1 (0x00007f6bf18c3000)
libc.so.6 => /lib64/libc.so.6 (0x00007f6bf14f6000)
libmql1.so => /u01/app/oracle/product/18.5.0/libmql1.so (0x00007f6bf1296000)
libipc1.so => /u01/app/oracle/product/18.5.0/libipc1.so (0x00007f6bf0e24000)
libnnz18.so => /u01/app/oracle/product/18.5.0/libnnz18.so (0x00007f6bf06cf000)
libons.so => /u01/app/oracle/product/18.5.0/libons.so (0x00007f6bf047f000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f6bf027b000)
libm.so.6 => /lib64/libm.so.6 (0x00007f6beff79000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f6befd5d000)
libnsl.so.1 => /lib64/libnsl.so.1 (0x00007f6befb43000)
librt.so.1 => /lib64/librt.so.1 (0x00007f6bef93b000)
libaio.so.1 => /lib64/libaio.so.1 (0x00007f6bef739000)
libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f6bef520000)
/lib64/ld-linux-x86-64.so.2 (0x00007f6bf5aab000)
libclntshcore.so.18.1 => /u01/app/oracle/product/18.5.0/libclntshcore.so.18.1 (0x00007f6beef3d000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f6beed27000)