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?
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
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
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.
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.