As I posted about nearly a year ago, I was (and still am) seeing Apache crashes caused by PHP extension ordering issues. So far, there has been no official or even unofficial workaround for the problem. I wrote a small shell script (/bin/sh for better portability) that will reorder the extensions in php.ini into the order that seems to cause the least problems for me.
Suggestions and improvements are more than welcome. I submitted this script to the PHP port maintainer for FreeBSD but have not yet heard back, which could be due to the hackishness of my script…
Anyhow, I’m pleased to announce that It Works For Me(TM) and you’re welcome to try it: fixphpextorder.sh
You may have to edit the file to correct pathnames and such, but if you build PHP from FreeBSD’s ports system, it should work. It’s especially nice when used with portupgrade like so:
portupgrade -A /root/bin/fixphpextorder.sh php5-\*
That will cause portupgrade to execute that script after each module is rebuilt. This will help if you have any cron or CLI PHP scripts that would reload modules while the upgrade is happening. I tried this method on several servers and it worked well. The only problem was a server running Cacti that polls every 5 minutes. I had two crashes while the upgrade was going on, but that is far better than the dozens it was getting when doing this by hand.
Update 11/21/07: I updated the script to also put pspell.so at the end of the file. It needs to be loaded after spl.so or PHP may crash Apache when a process terminates — either with a full shutdown or when an extra forked process is killed.
Update 6/25/08: Script updated to ensure spl.so comes before mysqli.so, which caused problems with PHP when used at the command line (CLI). Reported by Octaviao Ionescu.
Update 2/22/09: I updated the script again. I found that now sqlite.so must come after spl.so, or it complains about missing symbols. I also moved xml to the end hoping to fix another issue, but it did not help. It didn’t hurt, either, so I left the change in. Let me know if there are problems.
Update 1/21/10: Another script update. Had more crashes until I moved pdo/pdo_sqlite/pdo_mysql around a bit.