Making PHP play nice with Oracle, part 1

in PHP, oracle, oci8, ORA-24408

Today I came to work. It being Monday and all, seeing that PHP stopped talking to Oracle (which it was doing wonderfully until Friday), and that all reports are hence broken (which were not until Friday) is not a good start of the week. Add the cryptic Oracle errors, and you're set for nerve wrecking debugging.

I quickly found out that the problem was that the server was restarted by IT during the weekend due to "other issues". Not even gonna go there. The fact is, after a system reboot, PHP can no longer connect to Oracle, spawning the extremely helpful error "ORA-24408: COULD NOT GENERATE UNIQUE SERVER GROUP NAME" when calling oci_connect() (or similar).

No amount of cursing helped, and the usual debugging method (ie Googling around) showed that the dominant solution was to downgrade to OCI8 v.10. What the hell ?

Some saner guys mentioned that this is usually caused by an enviroment problem, but even after tinkering about nothing helped, so I'll skip to the good part -- the problem is that the server need to be able to resolve its own hostname to localhost.

That is, if your server hostname is myserver.local, then pinging myserver.local from itself should resolve to and NOT the server proper ip ( eg your intranet LAN ip ).

Do note that the safest way to see which is your hostname is to type "hostname" on the terminal (no quotes, duh). It might be more than you think!

Therefore, you simply add your hostname to the server /etc/hosts file and you're done. I have absolutely no flipping clue why this is, but it actually works. If you're one of the initiated Oracle clan members, kindly enlighten me; until someone does that though, I feel entitled to call this "requirement" a completely obnoxious badly document project breaking pain in the .. oh well.

Hope someone else benefits from my lack of hair.

Image from