Wednesday, December 22, 2010

menghubungkan oracle-xe dan php5 di ubuntu 10.04

#this is my documentation for private only

I assume linux ubuntu 10.04 with oracle-xe10g installed correctly and work normally

first step you mast install apache2 php5(php5-dev,phpize,lib**,etc) build-essential

####################################################################
*login as root
$su -i

*install apache2
#apt-get install apache2

*install php5
#apt-get install php5-common php5 php5-dev libapache2-mod-php5 php5-cli

*install build-essential&&php-pear
#apt-get install build-essential php-pear

*download instantclient-basic and instantclient-sdk from http://www.oracle.com/technetwork/topics/linuxsoft-082809.html
==> http://download.oracle.com/otn/linux/instantclient/112020/instantclient-basic-linux32-11.2.0.2.0.zip
==> http://download.oracle.com/otn/linux/instantclient/112020/instantclient-sdk-linux32-11.2.0.2.0.zip

*make directory in /opt
#mkdir /opt/oracle

*cp source instantclient(.zip file) from download directory to /opt/oracle
#cp -v /home/amri/Downloads/DTA/*.zip /opt/oracle

*goto directory /opt/oralce than unzip the package
#cd /opt/oracle
#unzip \*.zip

*rename unzipped directory
#mv instantclient_11_2 instantclient

*enter to the directory
#cd instantclient

*than make symlink
#ln -s libclntsh.so.11.1 libclntsh.so
#ln -s libocci.so.11.1 libocci.so

*create directory src on /opt/oracle for oci8 compiled dir
#mkdir /opt/oracle/src
#cd /opt/oracle/src

*download and compiling oci package
#pecl download oci8
#tar -xvf oci8-1.4.5.tgz
#cd oci8-1.4.5
#phpize
#export ORACLE_HOME=/opt/oracle/instantclient
#echo $ORACLE_HOME
#./configure --with-oci8=share,instantclient,/opt/oracle/instantclient
#make
#make install
#make test

*add oci module to php.ini
#echo extension=oci8.so >> /etc/php5/apache2/php.ini
#echo extension=oci8.so >> /etc/php5/cli/php.ini

*restart daemon apache2
#/etc/init.d/apache2 restart

*let's cek for phpinfo
#phpinfo.php
phpinfo();
?>

=>


*cek connection
#conn_oracle.php
$ora_user = 'hr';
$ora_pass = 'hr';
$ora_host = 'localhost';
$ora_db = 'hr';

$ora_conn = oci_connect($ora_user,$ora_pass,'//'.$ora_host.'/'.$ora_db);
if(!ora_conn){
$ora_conn_erno = oci_error();
echo ($ora_conn_erno['message']."\n");
oci_close($ora_conn);
} else {
echo "koneksi berhasil boss\n";
oci_close($ora_conn);
}
?>



Alhamdulillah,.. finish

###hope can be useful###