pdo_oci the Debian way (as much as possible)

31 03 2009

If you need generic instructions on how to compile a PHP5 module on Debian, please follow this link.

For pdo_oci you need to depart a bit from the canonical way. Follow these instructions in order to get a nicely built and installable debian package for it. Note that you need to have an Oracle client properly installed and configured for this module to be useful.

Below is a simple cake recipe for achieving that. Please modify according to your needs.

mkdir -p ~/src/php5
cd ~/src/php5
apt-get source php5
cd php5-5.2.6.dfsg.1/ext/pdo_oci
pecl package package2.xml

These steps will have generated a PDO_OCI-1.0.1.tgz archive. Now you want to make this package debian-ready. Begin by issuing the following command (found in the package dh-make-php):

dh-make-pecl --only 5 PDO_OCI-1.0.1.tgz

Now comes the magic. Enter the newly created directory php-pdo-oci-1.0.1 and edit the file debian/rules:

cd php-pdo-oci-1.0.1
vi debian/rules

Find the line that declares the constant PECL_PKG_NAME and change it from




Now look for the block

configure-stamp-v4 configure-stamp-v5:

There, right after the line that says

$(PHPIZE)$*; \

insert these lines:

sed -e 's/prefix\/include\/php\/ext/prefix\/include\/php5\/ext/' configure > /tmp/pdo_oci-configure; \
cp /tmp/pdo_oci-configure ./configure; \

Save the file and proceed with package creation:

dpkg-buildpackage -rfakeroot -us -uc

If no errors are reported, you will have just created a debian package into .. for pdo_oci ready to be installed by dpkg.

UPDATE: If you are having problems with your Oracle libs and/or includes not being found, try installing the instantclient packages (alien them from the RPMs found on Oracle’s downloads website). Here I am using the 11.2 x86_64 client. If yours differ, please adjust the paths accordingly.

First, make a symbolic link:

# cd /usr/lib/oracle/11.2/client64
# ln -s /usr/include/oracle/11.2/client64 ./include

Then, set some environment variables:

export ORACLE_BASE=/usr/lib/oracle/11.2
export ORACLE_HOME=$ORACLE_BASE/client64

And you should be good to go!




Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: