Apache and PHP
I had a call yesterday with someone looking for help with Php. I explained that I don’t do any Php and probably wouldn’t be able to help. He countered with “Well, it’s really Apache, not Php.”
I still demurred, but I let him describe the problem. First, it was a Debian system (another strike: I don’t know much about Debian either). There had been apt-get updates, and a reboot, and now php pages were not working at all.
Well, I hate to leave someone in the lurch, so I agreed that we could try to look at a few things. As I said, I don’t know beans about Php, or even how to configure it in Apache, but we went through the obvious things: is the module being loaded? Does Php itself exist? Is there an AddType for .php files? Ayup, all the config files were as they were before the update/reboot.. hmmm..
OK, I thought, let’s kill off all the current httpd processes and start up manually. Maybe that would give us a clue. I asked him to run “killall httpd”. He immediately came back wth “It says no such process”.
Well, OK, so Apache isn’t running. That’s what we want, or at least what I wanted right then.
“But it IS running”, my caller insisted. “Webmin says it’s running and it is serving up pages. Broken pages because Php isn’t working, but it definitely is running.”
OK, maybe “killall” is broken or he typed it wrong. I had him cd to /var/run and look for httpd.pid with the intention of finding it that way. To my surprise, he said it wasn’t there.
Sheesh. The server is running but it isn’t running? Debian can’t be that weird. I was scratching my head when he said “But there’s a thttpd.pid here.”
Huh? I asked him to do “lsof -i:80” and sure enough, it was thttpd listening on port 80. Before I could say another word he had checked and announced “Son of a gun – thttpd is set to run at startup.”
“Well, that’s going to stop httpd from starting”, I explained He shut down thttpd, started httpd and yelled “Yes!! It’s working!”
“That’s great”, I said. “I can’t tell you how thttpd got configured to run at startup, but at least we know why you couldn’t see your Php.”
As it turned out, everything wasn’t quite fixed. I got email from him later saying
“It still took me another 2-3 hours to get the website up. With your help, I got Apache/PHP running, but PHP still wasn’t talking to MySQL. By digging around with google for a couple of hours, I finally found that a line was missing from php.ini (extension=mysql.so). I added the line and everything came up as it should.”
So apparently the apt-get update messed with php.ini also. That really sounds strange to me – I don’t think any upgrade would ordinarily overwrite that. And how did thttpd get turned on?
Well, I don’t know. Surely there is an explanation, but for now it remains a mystery to me. You can visit the site at http://www.poetry4kids.com if you like.
*Originally published at APLawrence.com
A.P. Lawrence provides SCO Unix and Linux consulting services http://www.pcunix.com