Created
April 28, 2014 14:22
-
-
Save amolkhanorkar/11373627 to your computer and use it in GitHub Desktop.
Installing Oracle Instaclient with OCI8 drivers for PHP application.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Introduction | |
Contents | |
Introduction | |
Install RPMs | |
Integrate Oracle Libraries | |
ORACLE_HOME | |
SDK fix | |
Oracle Instant Client is a free Oracle database client. The current version is 11.2.0.1.0, and several versions back to 10.1.0.5 are available. | |
Install RPMs | |
Download the Oracle Instantclient RPM files from http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html. Everyone needs either "Basic" or "Basic lite", and most users will want "SQL*Plus" and the "SDK". | |
Convert these .rpm files into .deb packages and install using "alien" ("sudo apt-get install alien" if you don't have it): | |
alien -i oracle-instantclient-basic*.rpm | |
alien -i oracle-instantclient-sqlplus*.rpm | |
alien -i oracle-instantclient-devel*.rpm | |
Test your Instantclient install by using "sqlplus" to connect to your database: | |
sqlplus username/password@//dbhost:1521/SID | |
If sqlplus complains of a missing libaio.so.1 file, run | |
sudo apt-get install libaio1 | |
If sqlplus complains of a missing libsqlplus.so file, follow the steps in the section "Integrate Oracle Libraries" below. | |
If you execute sqlplus and get "sqlplus: command not found", see the section below about adding the ORACLE_HOME variable. | |
Integrate Oracle Libraries | |
If oracle applications, such as sqlplus, are complaining about missing libraries, you can add the Oracle libraries to the LD_LIBRARY_PATH each time it is used, or to add it to the system library list create a new file as follows: | |
sudo vi /etc/ld.so.conf.d/oracle.conf | |
and add the oracle library path as the first line. For example, | |
/usr/lib/oracle/11.1.0.1/client/lib | |
or | |
/usr/lib/oracle/11.2/client/lib/ | |
Then run ldconfig: | |
sudo ldconfig | |
====================================================================================================================== | |
Install some system applications | |
I started with a freshly installed Ubuntu 9.10 Server, and directly added several packages: | |
# apt-get install apache2 php5 php5-cli php-apc php5-xdebug php5-memcache php5-mcrypt php5-imagick php5-gd php5-xsl subversion imagemagick unzip htop memcached | |
In order to check if the extensions have been well configured, type the command "php -m" in the terminal, and they should display in the list. | |
Install Oracle Instant Client Libraries | |
Go to Oracle website, and download these two things: | |
Oracle instant client basic 10.2.0.4, zip packagew | |
Oracle instant client sdk 10.2.0.4, zip package | |
Put both of these files in /tmp. Then (yes, I know, it's the command horror show): | |
cd /tmp/ | |
unzip oracle-instantclient-basic-10.2.0.4-1.i386.zip | |
mv instantclient_10_2 /opt/ | |
unzip oracle-instantclient-devel-10.2.0.4-1.i386.zip | |
mv instantclient_10_2/sdk /opt/instantclient_10_2/ | |
export ORACLE_HOME=/opt/instantclient_10_2/ | |
ln -s /opt/instantclient_10_2/libclntsh.so.10.1 /opt/instantclient_10_2//libclntsh.so | |
ln -s /opt/instantclient_10_2/libocci.so.10.1 /opt/instantclient_10_2//libocci.so | |
ln -s /opt/instantclient_10_2/ /opt/instantclient_10_2/lib | |
PDO, PDO_OCI and OCI8 installation | |
The default PECL install does not work straight out of the box. You must download and build manually the packages: | |
pecl download pdo PDO_OCI OCI8 | |
tar xzvf PDO-1.0.3.tgz | |
tar xzvf oci8-1.3.5.tgz | |
tar xzvf PDO_OCI-1.0.tgz | |
cd PDO-1.0.3 | |
phpize | |
./configure | |
make | |
sudo make install | |
cd ../oci8-1.3.5 | |
phpize | |
./configure --with-oci8=instantclient,/opt/instantclient_10_2/ | |
make | |
sudo make install | |
cd ../PDO_OCI-1.0 | |
cp /opt/instantclient_10_2/sdk/include/*.h . | |
phpize | |
./configure | |
make | |
sudo make install | |
At that point, the libraries have been built but are not used by PHP. In this extent, you must add it at the bottom of php.ini files, /etc/php5/cli/php.ini and /etc/php5/apache2/php.ini: | |
extension = pdo.so | |
extension = pdo_oci.so | |
extension = oci8.so | |
Restart apache2 on server, thats it. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment