0) 设置 oracle 的语言环境变  
1)
安装 oracle client 相关包
   1>
下面 下载  : 
http://www.oracle.com/technology/tech/oci/instantclient/index.html           oracle-instantclient11.1-basic-11.1.0.7.0-1.x86_64.rpm
          oracle-instantclient11.1-devel-11.1.0.7.0-1.x86_64.rpm
          sdk-11.1.0.7.0-linux-x86_64.zip 
 
   2>
安装
         # 默认安装到 /usr/lib/oracle/11.1/client64/ 下面  
         rpm -ivh oracle-instantclient11.1-basic-11.1.0.7.0-1.x86_64.rpm 
  
         #
默认安装到 /usr/include/oracle/11.1/client64/ 下面  
         rpm -ivh oracle-instantclient11.1-devel-11.1.0.7.0-1.x86_64.rpm
 
       
Linux X86_64 下要进行如下设置
             ln -s /usr/lib/oracle/11.1/client64    /usr/lib/oracle/11.1/client
             ln -s /usr/include/oracle/11.1/client64    /usr/include/oracle/11.1/client 

    3> 
解压 sdk 并把里面的 sdk 包拷贝到 /usr/include/  
         unzip sdk-11.1.0.7.0-linux-x86_64.zip 
         cp -fr instantclient_11_1/sdk  /usr/include/ 
  
    
4> 设置 ORACLE_HOME LD_LIBRARY_PATH  NLS_LANG

        
/etc/profile 文件最后,添加如下三行
              export ORACLE_HOME=/usr/lib/oracle/11.1/client64/ 
              export LD_LIBRARY_PATH=/usr/lib/oracle/11.1/client64:$LD_LIBRARY_PATH
              export  NLS_LANG="AMERICAN_AMERICA.AL32UTF8"

       
使刚才的环境变量生效
              [root@[url]http://www.cnscn.org[/url] ~] # source /etc/profile

apache2.2:

# 编译和安装 apr 1.2
cd srclib/apr
./configure --prefix=/usr/local/apr
make; make install


#
编译和安装 apr-util 1.2
cd ../apr-util
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

make ;make install

./configure --prefix=/usr/local/apache2 --enable-mods-shared=all --enable-so --with-mpm=worker --enable-deflate --enable-cache --enable-disk-cache --enable-mem-cache --enable-file-cache --enable-proxy --enable-rewrite --enable-charset-lite --enable-suexec --with-suexec-bin=/usr/sbin/suexec --disable-ipv6 -disable-dav --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util

 

php5.2:( 要在安装好 oracle client 后装 )
 

  ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs  --with-oci8=instantclient,/usr/lib/oracle/10.2.0.4/client64/lib  --enable-track-vars --with-jpeg-dir --enable-fastcgi --enable-exif --enable-force-cgi-redirect --with-gd --with-zlib-dir --with-png-dir --with-ttf --with-freetype-dir --enable-gd-native-ttf --enable-gd-jis-conv --with-xml --enable-mbstring --with-iconv --enable-ftp --enable-bcmath  && make && make install
 
测试:
 ora.php
<?php
putenv("ORACLE_HOME=/usr/lib/oracle/10.2.0.4/client64/");
//putenv("LD_LIBRARY_PATH=/usr/lib/oracle/10.2.0.4/client64/");
putenv("ORACLE_SID=hanmi");
$user ="user"; // set user
$senha="password"; // set password
$banco="(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=TCP)
(HOST=123.123.123.123)(PORT=1521)
)
)
(CONNECT_DATA=(SERVICE_NAME=hanmi))
)"; // configuracoes do banco (isso muda um pouco no oracle)
if ($conexao = OCILogon($user,$senha,$banco))
echo "Conex?o bem sucedida.";
else
echo "Erro na conex?o com o Oracle.";
?> 
 

 

 

 

 

 

 

 

 

 

 参考:

Linux x86_64下为php安装pdo_ocioci8

 

 

0) 设置 oracle 的语言环境变量
   

1)
安装 oracle client 相关包
   1>
[url]http://www.oracle.com/technology/tech/[/url]oci/instantclient/instantclient.html 下载
          oracle-instantclient11.1-basic-11.1.0.7.0-1.x86_64.rpm
          oracle-instantclient11.1-devel-11.1.0.7.0-1.x86_64.rpm
          sdk-11.1.0.7.0-linux-x86_64.zip 
 
   2>
安装
         # 默认安装到 /usr/lib/oracle/11.1/client64/ 下面  
         rpm -ivh oracle-instantclient11.1-basic-11.1.0.7.0-1.x86_64.rpm 
  
         #
默认安装到 /usr/include/oracle/11.1/client64/ 下面  
         rpm -ivh oracle-instantclient11.1-devel-11.1.0.7.0-1.x86_64.rpm
 
       
Linux X86_64 下要进行如下设置
             ln -s /usr/lib/oracle/11.1/client64    /usr/lib/oracle/11.1/client
             ln -s /usr/include/oracle/11.1/client64    /usr/include/oracle/11.1/client 

    3> 
解压 sdk 并把里面的 sdk 包拷贝到 /usr/include/  
         unzip sdk-11.1.0.7.0-linux-x86_64.zip 
         cp -fr instantclient_11_1/sdk  /usr/include/ 
  
    
4> 设置 ORACLE_HOME LD_LIBRARY_PATH  NLS_LANG

        
/etc/profile 文件最后,添加如下三行
              export ORACLE_HOME=/usr/lib/oracle/11.1/client64/ 
              export LD_LIBRARY_PATH=/usr/lib/oracle/11.1/client64:$LD_LIBRARY_PATH
              export  NLS_LANG="AMERICAN_AMERICA.AL32UTF8"

       
使刚才的环境变量生效
              [root@[url]http://www.cnscn.org[/url] ~] # source /etc/profile

2)
安装 pdo_oci
    1>
安装 re2c
        wget [url]http://downloads.sourceforge.net/re2c/re2c-0.12.3.tar.gz[/url]
        ./configure
        make
        make install
 
    2>
安装 pdo_oci
       
下载 PDO_OCI-1.0.tgz
        wget [url]http://pecl.php.net/get/PDO_[/url]OCI-1.0.tgz

        tar xzvf PDO_OCI-1.0.tgz
        cd PDO_OCI-1.0
        /usr/local/php/bin/phpize

      
对刚安装的 oracle-instantclient11.1-basic  oracle-instantclient11.1-devel 进行设置
        ln -s /usr/include/oracle/11.1    /usr/include/oracle/10.2.0.3
        ln -s /usr/lib/oracle/11.1    /usr/lib/oracle/10.2.0.3
     
        ./configure --with-pdo-oci=instantclient,/usr,10.2.0.3
        
注意 , 按网上的教程 ./configure --with-pdo-oci=instantclient, /usr/lib/oracle/11.1/client64 ,11.1
        
则会到 /usr/lib/oracle/11.1/client64 /lib/oracle/11.1/client/lib 下面去寻找 oci.h header 文件 , 所以只能是
             ./configure --with-pdo-oci=instantclient,/usr,11.1
但会报错 configure: error: Unsupported Oracle version! 11.1
        
所以最终只能是
            
./configure --with-pdo-oci=instantclient,/usr,10.2.0.3
        
同理 /usr/lib/client64 

    3>
安装后生成 pdo_oci.so 在下面目录
          /usr/local/php/lib/php/extensions/no-debug-non-zts-yyyymmdd/pdo_oci.so
        
移动它到 /usr/local/php/lib/php/extensions/ 目录下  
         mv /usr/local/php/lib/php/extensions/no-debug-non-zts-yyyymmdd/pdo_oci.so ../ 
 
3)
安装 oci8  
  
下载 oci8 -1.3.4.tgz
     wget [url]http://pear.php.net/get/[/url]oci8-1.3.4.tgz
 
  
安装
    tar xzvf oci8-1.3.4.tgz
    cd oci8-1.3.4 
    /usr/local/php/bin/phpize
    ./configure --with-oci8=instantclient,/usr/lib/oracle/11.1/client64/lib
    make
    make install
 
  
安装后生成 /usr/local/php/lib/php/extensions/no-debug-non-zts-yyyymmdd/oci8.so
  
oci8 .so 移动到 /usr/local/php/lib/php/extensions/ 目录下
    mv /usr/local/php/lib/php/extensions/no-debug-non-zts-yyyymmdd/oci8.so ../ 
 
4)
修改 php.ini extension_dir 目录
    extension_dir = /usr/local/php/lib/php/extensions/
 
  
添加
     extension = pdo_oci.so
     extension = oci8.so

5)
重新启动 apache
  /usr/local/apache/bin/apachectl restart
 

  service httpd restart

6)
测试程序
  a)phpinfo.php
    <?php
      phpinfo();
  ?>

 

 

7) 测试程序

 

<?php

putenv("ORACLE_HOME=/usr/lib/oracle/10.2.0.4/client64/");

putenv("ORACLE_SID=hanmi");

$user ="user"; // set user
$senha="passwd"; // set password
$banco="(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=TCP)
(HOST=123.124.1.111)(PORT=1521)
)
)
(CONNECT_DATA=(SERVICE_NAME=hanmi))
)"; // configuracoes do banco (isso muda um pouco no oracle)

if ($conexao = OCILogon($user,$senha,$banco))
echo "Conex?o bem sucedida.";
else
echo "Erro na conex?o com o Oracle.";
?>