I wrote a PHP extension, and I’m trying to get it running on Mac’s Apache server.
It runs fine via the command line, for example:
$ php -r 'dl('mylib.dylib');
I also tried building Apache from source, and it works perfectly when I run that (I set it up to use the same PHP as Mac’s built-in Apache, too, so no difference there).
However, when I load my extension with the default Apache you get using System Preferences->Web Sharing or, equivalently, apachectl in sbin, it says:
Warning: dl() [function.dl]: Unable to load dynamic library '/usr/lib/php/extensions/mylib.dylib' - (null) in /Users/myuname/Sites/test.php on line 6
Is there something weird about Mac’s Apache or some permission for it that I have to set?
This sounds like the sort of error that would be caused by architecture differences. Try doing a
file /usr/lib/php/extensions/mylib.dyliband see which architectures are included in the binary. IIRC, Apache runs as 64-bit on Leopard, so you’ll need to make sure that your library includes code for the 64-bit version of whichever processor you’re running on (ppc64 or x86-64).