OCI8是访问oracle数据库的一个模组,在安装完oracle client and php package后,
The php patch they provided need to contain OCI so that PHP can connect to remote DB server using oracle client.
Please let php patch builder to refer to the following page:
下载一个oci8的一个比较新版本的包编译,解压后用这个替换php4.3.9/ext/oci8目录
#cd php-4.3.9
#./configure --prefix=/usr/oci --with-oci8=shared,$ORACLE_HOME
#make;make install
将会产生一个oci8.so文件,拷贝oci8.so到/usr/lib64/php/modules/,然后
#vi /etc/php.d/oci8.ini
; Enable oci8 extension module
extension=oci8.so
OR
#cd oci8-1.4.1
#phpize
#./configure --prefix=/usr/oci --with-oci8=shared,$ORACLE_HOME
#make;make install
Note:
if you encounter the issue as below when compiling oci8 Or launch httpd with load oci8 module:
Error: Unable to load dynamic library oci8.so, undefine zif_oci_define_by_name
Solution:
1, rm -f configure file under php-4.3.9 source folder
2, ./buildconf --force re-create configure file and re-compile oci8
Note:
1. Please add following in /etc/sysconfig/httpd:
export ORACLE_HOME=/home/oracle/OraHome1
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
export PATH=$PATH:$ORACLE_HOME/bin
2. Make sure the permission of /home/oracle is 755
restart httpd service then test the function of oci8 with PHP
# vi /var/www/html/conora.php
$dbstr ="(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST =10.224.114.23)(PORT = 1501))
(CONNECT_DATA =
(SID = szcndb)
(SERVICE_NAME = szcndb.qa.webex.com)))";
$conn = OCILogon("jabber", "pass", $dbstr );
$query = 'select count(*) from tabs';
$stid = OCIParse($conn, $query);
OCIExecute($stid, OCI_DEFAULT);
while ($succ = OCIFetchInto($stid, $row)) {
foreach ($row as $item) {
echo $item." ";
}
echo "
\n";
}
OCILogoff($conn);
?>
阅读(1298) | 评论(0) | 转发(0) |