Oracle Support for PHP

This section describes how configuring PHP to be able to connect to an Oracle server using oci8.

I first tested to use PDO_OCI (which should be compiled as for oci8 but first requires that you issue a pecl install PDO). However after lots of debugging, I could not make it work properly with TYPO3 as I had errors from AdoDB:

Dictionary driver ’/var/www/typo3_src-trunk/typo3/sysext/adodb/adodb/datadict/datadict-pdo.inc.php’ not available

Furthermore, after digging into DBAL’s code, there is code strictly testing oci8 (e.g., to dynamically replace the ’&’ (bitwise AND) operator to the Oracle-specific function, in typo3/sysext/dbal/class.ux_t3lib_sqlparser.php).

As such, I’m now using oci8. You need to have either the Oracle server locally or the Oracle client installed in order to be able to compile the oci8 module.

Installing oci8 on Debian Lenny

Compile the oci8 module against your version of PHP5:

# cd /tmp
# apt-get source php5
# cd php5-5.2.6.dfsg.1/ext/oci8/
# pecl install package2.xml

Create file /etc/php5/conf.d/oci8.ini:

# configuration for php OCI8 module
extension=oci8.so

Make sure it works:

# php -m | grep oci8

It’s time to restart Apache:

# /etc/init.d/apache2 restart

Installing oci8 on Red Hat Enterprise Linux 5

As time of writing, Red Hat Enterprise Linux 5 officially supports only PHP 5.1.6. First thing to do is to upgrade to PHP 5.2.x.

This section of the tutorial is adapted from  [1] to work on Red Hat Enterprise Linux 5 64 bits.

Get and install latest release of PHP 5.2:

# wget  http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-2.noarch.rpm
# wget  http://rpms.famillecollet.com/el5.x86_64/remi-release-5-7.el5.remi.noarch.rpm
# rpm -Uvh remi-release-5*.rpm epel-release-5*.rpm
# yum --enablerepo=remi update php php-\*

Install oci8 module for PHP:

# yum --enablerepo=remi install php-oci8

Fixing Issues

As I had to dig a bit to fix a few issues, here is what I had to do…

[Problem 1] Showing the loaded modules gives us an error:

# php -m
PHP Warning:  PHP Startup: Unable to load dynamic library ’/usr/lib64/php/modules/oci8.so’ -
/opt/oracle/product/11.1.0/client/libnnz11.so: cannot restore segment prot after reloc:
Permission denied in Unknown on line 0

This is the error due to SE Linux running in Enforce mode. The best way to avoid this is to make the SE Linux in Permissive mode. Change this by running:

# system-config-securitylevel

[Problem 2] Cannot load libclnts.so.11.1:

Create file /etc/ld.so.conf.d/oracle-client.conf:

/opt/oracle/product/11.1.0/client

run ldconfig:

# ldconfig

and restart Apache.

 

 

Causal Sàrl - Development, TYPO3, Consulting
Flattr