Author: Agbebiyi Babajide Adebiyi
Remark: ITS Documentation
Date: 22022009
Link: jide@live.co.za
INTRODUCTION
This documentation is intended to help quickly configure the TUT(Tshwane university of technology, SA) ITS connection. ITS connection is simply the Oracle database connection that TUT uses to store all crucial information about student and staff of TUT. This documentation hereby written for a simple purpose of connecting to this database to read information stored on TUT database.
PURPOSE
This documentation may be used by anyone testing, trying or wanting to build applications that connects to an oracle database system and also to help configure or recompile oracle(OCI8 installation with world’s powerful server scripting language php) on a LINUX OS.
HARDWARE AND SPECIFIIC CONFIG
OS:Linux
DISTRO: Centos
VERSION: 5
NEEDED TOOLS OR SOFTWARE
At the time of writing, the following versions were used
Oracle Instant client 11
PHP5
SETTING UP THE ENVIROMENT
1. Grab a copy of Oracle instantclient (basic and devel packages ) at http://www.oracle.com/technology/software/tech/oci/instantclient/index.html Note: I will illustrate using the .zip files. It is the same thing either you use rpm versions too.
mkdir -p /opt/oracle/instantclient
cd /opt/oracle/instantclient
unzip instantclient-basic-linux32-XXXXXXX.zip
unzip instantclient-sdk-linux32XXXXXX.zip
NB: Make sure all your instantclient files are in /opt/oracle/instantclient
We have to create symbolic links to some very crucial files in our instantclient folder.
cd /opt/oracle/instantclient
ln -s libclntsh.so.10.1 libclntsh.so libclntsh.so.10.1 will be whatever version you have
ln -s libocci.so.10.1 libocci.so
2. Now we have to download OCI8 module and build it ourselves. Grab it at http://pecl.php.net/package/oci8 .
mkdir -p /usr/local/srcs
cd /usr/local/srcs
Move the oci8 module to this folder created in step 3 above.
mv oci8-xxx.tgz /usr/local/srcs
tar xzf oci8-xxx.tgz
cd oci8-xxx
phpize
./configure --with-oci8=shared,instantclient,/opt/oracle/instantclient
make
make install
3. Edit your php.ini and add
extension=oci8.so
TESTING IF OCI8 IS ENABLED
Quickly write a phpinfo() script and see if you will see anything about oci8 like below
ENVIROMENT VARIABLE
type
export LD_LIBRARY_PATH= opt/oracle/instantclient
export TNS-ADMIN= opt/oracle
Grab and copy tnsnames.ora from your database administrator to
opt/oracle Folder
Restart apache server, depending on how you installed apache, traditionally use/etc/init.d/httpd restart
Run the phpinfo() script and look for image below about oci8
NB: The variable you might see may differ a bit due to difference in oci8
version but what is important is that you see oci8
MORE ENVIROMENT VARIABLE / START UP SCRIPT
You may want to create a script and set these environment variables, e.g. you can put in
/etc/rc.local – this script runs last during system startup ensuring that your connection to Oracle DB is always active
cd /etc/rc.local
type vi oci-init.sh
type the following command
/etc/init.d/httpd stop #stop web server and set environment
export LD_LIBRARY_PATH= opt/oracle/instantclient
export TNS-ADMIN= opt/oracle
/etc/init.d/httpd start
Thank you for using my how to, any comment, e-mail me, see above
Agbebiyi Babajide Adebiyi (Prince)