根据我的理解,以及之前的安装,要在centOs上使用PHP5.6安装oci8,我需要完成以下步骤:
使用RPM安装oracle-instantclient11.2-basic和oracle-instantclient11.2-devel。
使用pecl安装oci8 php扩展。
向php.ini添加扩展名。
这就是我在准备文件中所做的。

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块。
你知道我做错了什么吗?

最佳答案

使用“remi-php56”报告,您不需要从源代码构建扩展,所有内容都在存储库中;)
提供oci8版本2.0.12和pdo oci8的php-oci8
(pecl命令将只安装oci8扩展,而不是PDO驱动程序)
软件包使用Oracle客户机18c构建,允许连接到服务器版本18c、12.2、12.1和11.2。

08-07 04:54