Obviously, this has been successful for a number of people. I did finally get it installed on Ubuntu 10.04 Desktop 32bit, with much frustration. However, I never got it working on 64bit server.

Can someone point me to useful step-by-step instructions for getting a LAMP setup with PDO_OCI installed and working in Ubuntu Server? Preferably, I'd like to use 10.04 Lucid 64bit. If this is known to not work, or if a different version of Ubuntu Server is preferred, I'd like to know that too. I'm going to connect to an external Oracle server, so I don't need to know how to install the Oracle server stuff.

Thanks!

Comments

oshelot’s picture

What issues did you encounter on 64-bit that were not present on 32? Was it with compiling the PDO_OCI driver or something during the actual install process?

Shawn DeArmond’s picture

My issues were mostly that there is no good documentation, and what I ended up doing, I only managed to scrape from a half-dozen different articles spread across different linux versions, all advising to install stuff in different places. I honestly have no idea what I did that actually got the the 32bit working. I know it involved installing a bunch of different stuff from Oracle, pecl, and apt-get, patching some of it in random ways, and attempting to compile each time.

It finally worked with 32bit, but, like I said, I'm not likely to easily replicate my process.

I'm working on attempting a 64bit Lucid server install in the next week or two, and I hope to completely document my process. I'm just hoping that maybe somebody has written something definitive that would help me.

oshelot’s picture

I wrote a how to here http://inode.me/tutorials/how-to-drupal-7-oracle-xe-install which you may have already seen. Mine is on 32-bit only because Oracle doesn't release 10g XE in 64. I believe they did release the beta of 11g in 64 though. Anyway, I really don't see what difference there would be with 32/64-bit or the version of Linux for that matter. Why don't you try on a 64-bit and then post something when you have an error?

Shawn DeArmond’s picture

Status: Active » Needs review

Okay, I got it to work by throwing together a bunch of articles that I found on the web. Here is the documentation that seemed to work for me. Some of these commands I'm not sure WHY I had to do them (the article just said "Do this, trust me"). Also, even though it worked, I may have gotten instantclient 11.1 and 11.2 confused. So if there are unnecessary steps, or other fine-tuning that can be done, let's correct them here so we can submit a good docs page in the handbook.

All this time, I'm thinking: Why is this so hard? I guess it's mostly because PDO_OCI hasn't been updated since 2005.

Oracle Clients on 10.04 Ubuntu Server 64-bit

10.04.3 installer image

## During Installation, select these server types:
LAMP Server
OpenSSH Server

## Download Oracle OCI clients for Linux:
http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
## Download to /usr/lib/oracle/:
instantclient-basic-linux-x86-64-11.2.0.2.0.zip
instantclient-sqlplus-linux-x86-64-11.2.0.2.0.zip
instantclient-sdk-linux-x86-64-11.2.0.2.0.zip

## Unzip files to instantclient_11_2/ and rename repository

$ sudo apt-get install unzip
$ cd /usr/lib/oracle/
$ sudo unzip instantclient-basic-linux-x86-64-11.2.0.2.0.zip
$ sudo unzip instantclient-sqlplus-linux-x86-64-11.2.0.2.0.zip 
$ sudo unzip instantclient-sdk-linux-x86-64-11.2.0.2.0.zip 
$ sudo mv instantclient_11_2 instantclient

## Setup $ORACLE_HOME and associated links

$ cd ~
$ vi .bashrc

#Insert the following lines to the bottom of .bashrc
export ORACLE_HOME=/usr/lib/oracle/instantclient
export LD_LIBRARY_PATH=$ORACLE_HOME/
export TNS_ADMIN=/etc
export NLS_LANG=AMERICAN_AMERICA.UTF8

#Exit vi (ZZ)
$ source .bashrc

## Install extra php stuff

$ sudo apt-get install php5-dev php-pear php-db php-gd php5-curl
$ sudo apt-get install build-essential libaio1

## The installers all look for stuff in the wrong place. These links make it so it doesn't matter.

$ sudo su -
$ ln -s libclntsh.so.* libclntsh.so
$ ln -s libocci.so.* libocci.so
$ echo /usr/lib/oracle/instantclient >> /etc/ld.so.conf
$ ldconfig

#Install OCI8

$ pecl install oci8
prompt> shared,instantclient,/usr/lib/oracle/instantclient

# Create a file: /etc/php5/cli/conf.d/oci8.ini
extension=oci8.so

# More links so the installers don't get confused.
$ cd /usr/include/
$ ln -s php5 php

$ cd /usr/lib/oracle/instantclient

$ mkdir -p include/oracle/11.1/
$ cd include/oracle/11.1/
$ ln -s ../../../sdk/include client
$ cd -

$ mkdir -p lib/oracle/11.1/client
$ cd lib/oracle/11.1/client
$ ln -s ../../../../ lib

## Download PDO_OCI

$ mkdir -p /tmp/pear/download/
$ cd /tmp/pear/download/
$ pecl download pdo_oci
$ tar xvf PDO_OCI*.tgz
$ cd PDO_OCI*

## Patch PDO_OCI since it hasn't been updated since 2005
# copy the lines below into the file "config.m4.patch"

*** config.m4	2005-09-24 17:23:24.000000000 -0600
--- config.m4	2009-07-07 17:32:14.000000000 -0600
***************
*** 7,12 ****
--- 7,14 ----
    if test -s "$PDO_OCI_DIR/orainst/unix.rgs"; then
      PDO_OCI_VERSION=`grep '"ocommon"' $PDO_OCI_DIR/orainst/unix.rgs | sed 's/[ ][ ]*/:/g' | cut -d: -f 6 | cut -c 2-4`
      test -z "$PDO_OCI_VERSION" && PDO_OCI_VERSION=7.3
+   elif test -f $PDO_OCI_DIR/lib/libclntsh.$SHLIB_SUFFIX_NAME.11.1; then
+     PDO_OCI_VERSION=11.1    
    elif test -f $PDO_OCI_DIR/lib/libclntsh.$SHLIB_SUFFIX_NAME.10.1; then
      PDO_OCI_VERSION=10.1    
    elif test -f $PDO_OCI_DIR/lib/libclntsh.$SHLIB_SUFFIX_NAME.9.0; then
***************
*** 119,124 ****
--- 121,129 ----
      10.2)
        PHP_ADD_LIBRARY(clntsh, 1, PDO_OCI_SHARED_LIBADD)
        ;;
+     11.1)
+       PHP_ADD_LIBRARY(clntsh, 1, PDO_OCI_SHARED_LIBADD)
+       ;;
      *)
        AC_MSG_ERROR(Unsupported Oracle version! $PDO_OCI_VERSION)
        ;;

## Build and install PDO_OCI

$ patch --dry-run -i config.m4.patch
$ patch -i config.m4.patch
$ phpize
$ ORACLE_HOME=/usr/lib/oracle/instantclient ./configure --with-pdo-oci=instantclient,/usr/lib/oracle/instantclient,11.1
$ make
$ make test
$ make install

## Add extensions to PHP
# Create /etc/php5/apache2/conf.d/pdo_oci.ini

extension=pdo_oci.so

## restart Apache

$ /etc/init.d/apache2 restart

## Install Drupal, Drush, Oracle client, etc. like normal.

aaaristo’s picture

thanks Shawn for the contributed docs... i hope someone find the time to review it and patch the INSTALL.txt ;)

aaaristo’s picture

Priority: Normal » Minor
radalin’s picture

You might use Zend Server CE for a ready to use Oracle stack. even though it includes, it's own apache etc. It's easy to start from scratch. It comes preinstalled with some goodies (or bloatware) and it's ready for prod too.

Anonymous’s picture

I got it working!! Here is my revised version of this howto:

Installing the PHP_OCI driver for Oracle databases

This step-by-step was adapted from the Ubuntu howto above. It worked for me on Debian/Linux64 Lenny (5.0) in the year 2012. As I wrote up this howto I tested a few things and ran into a new error... but my initial run through was successful. Good luck!

Please note: the patch you will do uses "11.1" as the version number. It will work with version 11.2 and later (but unless you update the patch, you should continue using "11.1" in the ./configure command).

## Download the following instantclient files from Oracle's website
http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html

unzip instantclient-basic-linux-x86-64-11.2.0.2.0.zip
unzip instantclient-sdk-linux-x86-64-11.2.0.2.0.zip

## Move the files to our install location, /usr/lib/oracle/instantclient

mkdir /usr/lib/oracle
mv instantclient_11_2/ /usr/lib/oracle/instantclient

## Fix some poorly named files and add them to our system's library index:

cd /usr/lib/oracle/instantclient
ln -s libclntsh.so.* libclntsh.so
ln -s libocci.so.* libocci.so
echo /usr/lib/oracle/instantclient >> /etc/ld.so.conf
ldconfig

## Fix more stupid paths:

mkdir -p include/oracle/11.1/
cd include/oracle/11.1/
ln -s ../../../sdk/include client
cd /usr/lib/oracle/instantclient

mkdir -p lib/oracle/11.1/client
cd lib/oracle/11.1/client
ln -s ../../../../ lib

## Download PDO_OCI

mkdir -p /tmp/pear/download/
cd /tmp/pear/download/
pecl download pdo_oci
tar -xvzf PDO_OCI*.tgz
cd PDO_OCI*

## Patch PDO_OCI since it hasn't been updated since 2005
# copy the lines below into the file "config.m4.patch"

*** config.m4 2005-09-24 17:23:24.000000000 -0600
--- config.m4 2009-07-07 17:32:14.000000000 -0600
***************
*** 7,12 ****
--- 7,14 ----
    if test -s "$PDO_OCI_DIR/orainst/unix.rgs"; then
      PDO_OCI_VERSION=`grep '"ocommon"' $PDO_OCI_DIR/orainst/unix.rgs | sed 's/[ ][ ]*/:/g' | cut -d: -f 6 | cut -c 2-4`
      test -z "$PDO_OCI_VERSION" && PDO_OCI_VERSION=7.3
+   elif test -f $PDO_OCI_DIR/lib/libclntsh.$SHLIB_SUFFIX_NAME.11.1; then
+     PDO_OCI_VERSION=11.1   
    elif test -f $PDO_OCI_DIR/lib/libclntsh.$SHLIB_SUFFIX_NAME.10.1; then
      PDO_OCI_VERSION=10.1   
    elif test -f $PDO_OCI_DIR/lib/libclntsh.$SHLIB_SUFFIX_NAME.9.0; then
***************
*** 119,124 ****
--- 121,129 ----
      10.2)
        PHP_ADD_LIBRARY(clntsh, 1, PDO_OCI_SHARED_LIBADD)
        ;;
+     11.1)
+       PHP_ADD_LIBRARY(clntsh, 1, PDO_OCI_SHARED_LIBADD)
+       ;;
      *)
        AC_MSG_ERROR(Unsupported Oracle version! $PDO_OCI_VERSION)
        ;;

## Attempt to compile (this is where you're probably stuck, make sure you're in your PDO_OCI folder!)

export ORACLE_HOME=/usr/lib/oracle/instantclient 
patch --dry-run -i config.m4.patch
patch -i config.m4.patch
phpize
./configure --with-pdo-oci=instantclient,/usr/lib/oracle/instantclient,11.1
make
make test
make install

## Add extensions to PHP
# Create /etc/php5/apache2/conf.d/pdo_oci.ini
extension=pdo_oci.so

## restart Apache
/etc/init.d/apache2 restart

Congratulations you made it!

## install Drupal!
Read the INSTALL file in the Drupal oracle module. It must be put in a special place in Drupal's filesystem!

bencornwell’s picture

Awesome! That worked perfectly, thank you! You've ended many hours of frustration!

bencornwell’s picture

Issue summary: View changes

added clarity regarding Oracle Server.

jurgenhaas’s picture

I followed all instructions from comment #8 and got as far as to
./configure --with-pdo-oci=instantclient,/usr/lib/oracle/instantclient,11.1
which closes with an error: Cannot find php_pdo_driver.h.

Any idea what I'm doing wrong?

jurgenhaas’s picture

Found a solution here (http://berryllium.nl/2012/02/configure-error-cannot-find-php_pdo_driver-...):
ln -s /usr/include/php5 /usr/include/php

baldasso’s picture

Issue summary: View changes

If you get an error:

/tmp/pear/download/PDO_OCI-1.0/pdo_oci.c:34:1: error: unknown type name ‘function_entry’

change function_entry in pdo_oci.c to zend_function_entry

Anonymous’s picture

Hey folks, two years later still seeing updates on this issue I want to throw in my 2¢ on how I would approach this in the future since I'm not maintaining the revised instructions I provided above. Hopefully it will save some time for the next person(s) going down this trail.

With the driver and installing the DB I would have been better off using a derivative of RedHat, because that is what it is written for. Further, I would not bother looking at virtualization of the environment as Oracle DBs like hardware. Augmenting config for Debian/Ubuntu/etc. in the long run is going to be a hassle, mainly because of library linking and the old drivers not knowing about newer compatible versions of things.

What you probably want to do to make your life easier is find an old PC, download Oracle's version of Linux (based on RedHat) which has all of this stuff either built-in or ready-to-go. Install it on your old laptop or something. Or find a hardware host that will let you provide your own ISO and use Oracle's. Install whatever you need to run Drupal, and then check out your code from your version control onto that machine and proceed from there.

If you're considering co-building with a tried-and-true database like MySQL/MariaDB alongside your Oracle version you might consider using Migrate to stage content if it isn't accessible to the client. Or you could do some fancy networking.

oshelot’s picture

I just migrated my site from oracle-XE 10.2 to 11.2. I used a standard CentOS 6.2. While I much prefer Ubuntu, a little research will reveal that running on a Redhat variant will make your life easier (first clue, no dpkg). Installed all the prerequisite packages along with the instantclient-{basic,devel} rpms. That part is simple enough. The problem here is that PDO_OCI isn't maintained so you have to patch config files and symlink stuff just to compile against 11.x libraries. It wouldn't be such a pain if these patches were just committed.

Anonymous’s picture

Oh one more thing that has come to my attention since doing this stuff... DBTNG Migrator. This allows you to convert between database types. So if you have a MySQL based site, and you managed to get the Oracle driver installed, you can set the Oracle DB as secondary in your settings.php and use this module to transform the MySQL data into Oracle form. I have tried this doing MySQL -> SQLite and it worked perfectly.