In the past I wrote an article how to connect to a IBM DB2 database with PHP on Windows. Now i need to connect from a Red Hat Enterprise Linux to the DB2 database. I have searched the internet for good tutorials. I have found a few, but these aren’t so good.
So I will describe here how to install PHP 5.2.1 with IBM DB2 support on an Apache 2.0.59.
First download the packages:
Copy the Packages to
/usr/local/src/lampand unpack it as root. To unpack both packages at the same time write this to your console:
for i in `ls *.gz`; do tar zxf $i; done;In the next step will Apache be configured and compiled.
- Change the directory to the unpacked Apache directory:
cd /usr/local/src/lamp/httpd-2.0.59 - Start the configure script
./configure --prefix=/usr/local/httpd \
--enable-modules=all \
--enable-so - To compile Apache type
maketo your command line
- Install Apache with
make install
To start Apache at boottime you will copy the startscript and create links to the runlevel 3.
Do this on your command line:
-
cp /usr/local/httpd/bin/apachectl /etc/rc.d/init.d/httpd -
cd /etc/rc.d/rc3.d -
ln -s ../init.d/httpd S20httpd -
ln -s ../init.d/httpd K20httpd
Now set user and group of
/usr/local/httpd/htdocsto nobody
chown -R nobody:nobody /usr/local/httpd/htdocs/
Now compile and install PHP 5.2.1. I write the naked comand line instructions
-
cd /usr/local/src/lamp/php-5.2.1/ -
./configure --with-apxs2=/usr/local/httpd/bin/apxs \
--with-zlib-dir=/usr/lib \
--enable-versioning \
--enable-track-vars=yes \
--enable-url-includes \
--enable-sysvshm=yes \
--enable-sysvsem=yes \
--enable-ftp \
--enable-calendar \
--with-config-file-path=/etc \
--with-ibm-db2=/home/db2inst1/sqllib - Now you have to login as your database user like
db2inst1 -
cd /usr/local/src/lamp/php-5.2.1/ -
make - Logout and login as root
-
cd /usr/local/src/lamp/php-5.2.1/ -
make install -
cp /usr/local/sr/lamp/php-5.2.1/php.ini-dist /etc/php.ini
At the last step you have to tell apache which are php files. Add in
/usr/local/httpd/conf/httpd.confthese two lines: ATTENTION: Only root can edit httpd.conf!
AddType application/x-httpd-php php
AddType application/x-httpd-php-source phpsSerch in the
httpd.conffor
DirectoryIndex index.htmland replace it with
DirectoryIndex index.html index.phpNow you can start your Apache server with PHP and DB2 support with this command
/etc/init.d/httpd startResources:
Post Questions as a comment.

[...] this post I wrote how to install Apache and PHP. I installed PEAR on this testerver too. My document [...]