Oracle Instant Client on Ubuntu Dapper 6.06
Posted: Tue Sep 05, 2006 11:55 am
This howto should provide step-by-step details of how to get php with OCI8 up and running, using Oracle's instant client - and NOT the full client install.
Info: This information is based on this article and this one.
I'm running Ubuntu Server (Dapper 6.06) on an ST20G5 shuttle PC - so I used the "Instant Client for Linux x86-64".
1) Download those files:
a) Instant Client Package - Basic: All files required to run OCI, OCCI, and JDBC-OCI applications
instantclient-basic-linux-x86-64-10.2.0.2-20060228.zip (35,625,985 bytes) (cksum - 2403915938)
b) Instant Client Package - SDK: Additional header files and an example makefile for developing Oracle applications with Instant Client
instantclient-sdk-linux-x86-64-10.2.0.2-20060228.zip (602,431 bytes) (cksum - 1689085455)
(Optional, but valuable for debugging / testing):
c) Instant Client Package - SQL*Plus: Additional libraries and executable for running SQL*Plus with Instant Client
instantclient-sqlplus-linux-x86-64-10.2.0.2-20060228.zip (789,007 bytes) (cksum - 1598071762)
2) "cd" to to /opt/oracle/instantclient and unzip the files there.
2b) Create some symlinks which should be there, but aren't:
3) Download and compile the OCI8 package:
4) Enable name resolving:
4a) set important environment variables.
(Here's a small script that will help testing)
4b) Now create a tnsnames.ora in $TNS_ADMIN:
...and fill it with some meaningful content - like this:
4c) Test if name resolving and connectivity works so far:
run:
and check if you can connect to MYDB at all.
5) Let php know that it has a new extension:
In "php.ini" (/etc/php5/apache2/php.ini and /etc/php5/cli/php.ini), add a line(put this line after the examples starting with ;extension).
6) Apache needs to know about the environment variables too, so change its startup script "/etc/init.d/apache2", by changing this:
- to: -
Info: This information is based on this article and this one.
I'm running Ubuntu Server (Dapper 6.06) on an ST20G5 shuttle PC - so I used the "Instant Client for Linux x86-64".
1) Download those files:
a) Instant Client Package - Basic: All files required to run OCI, OCCI, and JDBC-OCI applications
instantclient-basic-linux-x86-64-10.2.0.2-20060228.zip (35,625,985 bytes) (cksum - 2403915938)
b) Instant Client Package - SDK: Additional header files and an example makefile for developing Oracle applications with Instant Client
instantclient-sdk-linux-x86-64-10.2.0.2-20060228.zip (602,431 bytes) (cksum - 1689085455)
(Optional, but valuable for debugging / testing):
c) Instant Client Package - SQL*Plus: Additional libraries and executable for running SQL*Plus with Instant Client
instantclient-sqlplus-linux-x86-64-10.2.0.2-20060228.zip (789,007 bytes) (cksum - 1598071762)
2) "cd" to to /opt/oracle/instantclient and unzip the files there.
2b) Create some symlinks which should be there, but aren't:
Code: Select all
n -s libclntsh.so.10.1 libclntsh.so
ln -s libocci.so.10.1 libocci.so
Code: Select all
pecl download oci8
tar -xzf oci8-1.2.2.tgz
cd oci8-1.2.2.tgz
phpize
./configure --with-oci8=shared,instantclient,/opt/oracle/instantclient
make
make install
4a) set important environment variables.
(Here's a small script that will help testing)
Code: Select all
#!/bin/sh
LD_LIBRARY_PATH=/opt/oracle/instantclient:${LD_LIBRARY_PATH}
TNS_ADMIN=/etc/oracle
export LD_LIBRARY_PATH TNS_ADMIN
Code: Select all
mkdir -p $TNS_ADMIN
vi $TNS_ADMIN/tnsnames.ora
Code: Select all
MYDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = mymachine.mydomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = MYDB)
)
)
run:
Code: Select all
sqlplus username@MYDB
5) Let php know that it has a new extension:
In "php.ini" (/etc/php5/apache2/php.ini and /etc/php5/cli/php.ini), add a line
Code: Select all
extension=oci8.so
6) Apache needs to know about the environment variables too, so change its startup script "/etc/init.d/apache2", by changing this:
Code: Select all
ENV="env -i LANG=C PATH=/usr/local/bin:/usr/bin:/bin"
Code: Select all
ENV="env -i LANG=C PATH=/usr/local/bin:/usr/bin:/bin"
ENV="$ENV TNS_ADMIN=/etc/oracle LD_LIBRARY_PATH=/opt/oracle/instantclient"