我用的安装包,可以共享给大家
安装包
实行命令rpm -ivh oracle-instantclient-basic-10.2.0.5-1.x86_64.rpmrpm -ivh oracle-instantclient-devel-10.2.0.5-1.x86_64.rpm
rpm -ivh oracle-instantclient-sqlplus-10.2.0.5-1.x86_64.rpm
实行以下命令检讨安装是否完毕:
rpm -qa | grep oracle
安装成功
二、修正系统配置创建32位软连接
ln -s /usr/lib/oracle/10.2.0.5/client64 /usr/lib/oracle/10.2.0.5/client
ln -s /usr/include/oracle/10.2.0.5/client64 /usr/include/oracle/10.2.0.5/client
三、添加环境变量编辑/etc/profile,在最下面添加以下几行:
export ORACLE_HOME=/usr/lib/oracle/10.2.0.5/client64
export LD_LIBRARY_PATH=/usr/lib/oracle/10.2.0.5/client64:$LD_LIBRARY_PATH
export NLS_LANG="AMERICAN_AMERICA.AL32UTF8"
使环境变量立即生效
source /etc/profile
四、编译PHP扩展1.查看PHP版本相关信息2.编译安装oci8扩展tar -xvzf oci8-2.0.5.tgz
cd oci8-2.0.5.tgz
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-oci8=instantclient,/usr/lib/oracle/10.2.0.5/client64/lib
make && make install
3.修正php.ini,启用扩展编辑/usr/local/php/etc/php.ini文件,并加入如下配置:
extension=oci8
4.检讨安装是否精确php --ri oci8
五、编译PHP扩展
private $config = [ 'connection_string' => '10.20.2.13/orcl', "username"=>"zfsoft_zjk", "password"=> "zjk_GMUXS333MS",];
$conn = oci_connect($this->config['username'],$this->config['password'],$this->config['connection_string']);if(!$conn){ $e = oci_error(); print htmlentities($e['message']); exit;}else{ echo "连接oracle成功!
";}
$sql = "select from jw_user.md_subject";$ora_test = oci_parse($conn,$sql); //编译sql语句oci_execute($ora_test,OCI_DEFAULT); //实行while($row = oci_fetch_array($ora_test,OCI_RETURN_NULLS)){ print_r($row);}
到此即可打印出每一条数据!
!
下一篇:
php 连接 Sql Server