DB2 php pdo driver not found by apache webserver

I use php code to display db2 database query results in web pages served by apache.

It worked with openSUSE 12.1 and DB2 Express-C 9.7.x by sourcing the instance profile /home/db2inst1/sqllib/db2profile of DB2 in /etc/sysconfig/apache2.

After migrating to DB2 10.1 it no longer works.
I guess it is related to systemd which is used as replacement for SysV init by openSUSE 12.1
systemd is said to “better” control the environment passed to the started services.
Looks like systemd thinks DB2 environment is evil and filters it out.
But then, I have no idea why it worked with DB2 9.7.

Strange enough, while this does not work (php exception “could not find driver” during db connect):

/etc/init.d/apache2 start
This does work

bash /etc/init.d/apache2 start
Anyone had similar problems or even has a solution for this?

To check if systemd is the culprit, you onley have to use the old sysvinit at your next boot. Simple test I should say.

Oh, somehow my post got lost where I said something like:

I found out now how to replace systemd with SysV init (just add init=/sbin/sysvinit to kernel command line in /boot/grub/menu.lst)

When I do that db2 access works just fine again.

Questions remain: why? And how to fix without abandoning systemd?

Maybe somebody knows how to fix this. You could also report this on openSUSE:Submitting bug reports - openSUSE

In the mean time, what is against using SysVinit until systemd is stable? No hurry I should think.

Well, if everybody waits and uses SysV init, systemd will never be ready. No hurry though, thats right.
And, somebody knows now how to fix it: me :slight_smile:

systemd interprets /etc/sysconfig/<service> files strictly as environment variable definitions while SysV init sources them like normal shell scripts, and that includes including other files like I did with the db2profile.

Solution was to not start the service directly but a shell and let it interpret my db2profile before starting the service.
In my case I copied /lib/systemd/system/apache2.service to /etc/systemd/system/ and changed the line

ExecStart=/usr/sbin/start_apache2 -D SYSTEMD -k start


ExecStart=/bin/bash -c '. /home/db2mspr/sqllib/db2profile; /usr/sbin/start_apache2 -D SYSTEMD -k start'


Nice analysing! :shake:

It is good for your selfesteem to make solutions like that.

It seems like your DB2 database file gets corrupt or damaged and so that you have to fix it by using an updated backup file. You can also try any third party tool to fix DB2 database.

There is also the ExecPre entry in which you can probably place your sourcing. see

man 5 systemd.service

Just saying :). Any way this issue should be fix with the new “sysemd version 208” which you can find in 13.1

I assume you mean ExecStartPre? That does not interpret shell syntax either, which means I have to launch a shell, too. And that means, the sourced variables are only available within this shell and its children and not later in ExecStart for the start_apache2 to see them.

And then, what would I need to do to tell systemd 208 that I want to source that profile for start_apache2? I don’t see how that should work. can you explain, please?

A lot fix for systemd version 208 so you can check it out if have the time. Also if you have to do more lines in your ExecStart i suggest you create a script and point it to your ExecStart.