Oracle 10 and 11

Since Oracle is a proprietary package, most Linux distributions do not include the binary libraries needed to connect to it. Thus while you can use the package installer to install the necessary database agnostic generic drivers, you have to do additional work to get the actual database drivers to work. In this section, we will outline the steps needed to get the necessary parts installed for Oracle to work from both Perl and PHP5.

Oracle Perl Driver

The first step to getting WACS to work with Oracle is to download a suitable set of client side applications and libraries - these are typically provided by Oracle 11i Instant Client or a package of a similar name. Of course this does not include the database itself but when using the likes of Oracle, it would be quite normal (but not required) to have separate web servers and database engines. Wacs works just fine on multiple front end web servers with a single Oracle backend. Similarly collection administration and straightforward use can be performed on a separate workstation from hosting the database.

Generally doing a full install of instant client will provide all the libraries you need. If you are downloading these from the Oracle OTN web site, you will need the following packages either as zip files or rpms if that is the package manager on the distribution you are using.

Table 12.1. Required Client Side Oracle Packages

ComponentPackage Name
Basic Librariesoracle-instantclient11.2-basic-11.2.0.2.0.x86_64.rpm
Developement (SDK)oracle-instantclient11.2-devel-11.2.0.2.0.x86_64.rpm
ODBC (Useful, not reqd)oracle-instantclient11.2-odbc-11.2.0.2.0.x86_64.rpm
SqlPlus (Command Line)oracle-instantclient11.2-sqlplus-11.2.0.2.0.x86_64.rpm

The next step is to establish the necessary ORACLE_HOME environment variables and check that the Oracle stack is running by connecting to the server using the sqlplus client (called sqlplus64 on the x86_64 version) provided as part of the instant client package. If this reports that the necessary shared libraries are not found, this may be because the dynamic library caching configuration files have not been created as needed. For RedHat based distros like Fedora, this is achieved by creating a file in /etc/ld.so.conf.d/ called something like oracle-11g-installclient.conf which simply contains a single line pointing to where the files like libsqlplus.so are to be found. For the x86_64 version of instantclient installed from the RPMs, this should be /usr/lib/oracle/11.2/client64/lib assuming the RPM was installed into it's default locations. Once this file has been created, you just need to run ldconfig as root to rebuild the /etc/ld.so.cache to include the files in this path.

If you get the message sqlplus64: error while loading shared libraries: libnnz11.so: cannot enable executable stack as shared object requires: Permission denied that means that SELinux is still active on your host and has barred access to the Oracle libraries. The quick fix is to disable SELinux by running setenforce permissive as root on your machine and editing the file /etc/selinux/config to set the mode to permissive on subsequent system boots.

Once you've actually got the sqlplus program to run, that is unfortunately not usually the end of the story as it has to be configured to find the database server, etc. There are two parts to this task - firstly to create a suitable tnsnames.ora file to describe how to contact your server - place this into a newly-made /etc directory within the oracle instant client directory. Secondly you need to set environment variables that tell instant client what to look up within that tnsnames.ora file. This is done by establishing four environment variables, ideally globally for the system - these are:

Table 12.2. Oracle Environment Variables

VariableTypical Value
ORACLE_HOME/usr/lib/oracle/11.2/client64
ORACLE_SIDyourdbname
TWO_TASKyourdbname
TNS_ADMIN/usr/lib/oracle/11.2/client64/etc

In many ways the best way to establish these environment variables is to create the appropriate files in the global profiles directory, which is to be found in /etc/profile.d. Typically it's best to create two files called something like oracle11g-instantclient.sh with commands for sh/bash shells, and oracle11g-instantclient.csh with commands for csh/tcsh shells. The shell (.sh) file should look something like this:

export ORACLE_HOME=/usr/lib/oracle/11.2/client64
export ORACLE_SID=yourdbname
export TWO_TASK=yourdbname
export TNS_ADMIN=/usr/lib/oracle/11.2/client64/etc
alias sqlplus=sqlplus64

It should then be a fairly simple matter of using cpan DBD::Oracle to download, compile and install the necessary database driver for Perl DBI. Once that's done, you just need to follow the installation instructions for Oracle in the appropriate chapters of this guide.

Oracle Php5 Driver

The conventional install of Php5's pear DB routines actually does include the first line of support for Oracle in the form of the oci8.php file in /usr/share/pear/DB but this itself needs oci8.so which normally lives in /usr/lib64/php/modules. To make this module, you will need the full set of SQL*Net libraries as provided by either a full database installation or Oracle's instant client product. You will also need the C compiler and the php-devel package (this contains the command phpize so if trying to invoke phpize gives Command not found you almost certainly don't have the necessary development package installed.

Since WACS currently uses the now-obsolete Pear DB module for database access, it appears to be a bit of a challenge to find the correct source code. While we were preparing this document (March 2011), the source code for the OCI8 driver could be found at the PECL web site. If you down load this with something like wget and save it locally, running the following (assuming you have ORACLE_HOME set correctly) as root produced a successful install: pecl install oci8. You then need to enable the extension in php itself; in some distros this is done by simply adding extension=oci8 into the /etc/php.ini file, while in more recent distros it is now convention to create a file called oci8.ini in the directory /etc/php.d containing this line. Once this configuration change has been made, you will need to restart your web server to make the new settings live. All that then remains to be done is to configure the phpdbconnect string in the main wacs configuration file with the correct database specification and things should start to work.