While working a new project of mine, SoapSource: a soap datasource for Cakephp, I wanted to make use of PHP’s SOAP extension. As I figured out quickly the default install of PHP on Mac OS X Leopard isn’t compiled with the SOAP extension enabled. So I thought; that’s easy, just recompile PHP with the SOAP extension enabled.. However I encountered some serious problems.
It appears to be impossible to compile a 64bit version of PHP on Mac OS, there’s some sort of bug with ‘libiconv’.
So next idea, recompile Apache in 32bit, Mysql in 32bit and ofcourse PHP in 32bit… well again I didn’t succeed, so I reverted all my changes back to the original settings after a day of hard work and frustrations.
But then I found out you can compile dynamic extensions without recompiling your entire PHP installation. So I got SOAP running within 5 minutes using to following instructions:
Download the PHP source of the version your Mac is running, probably PHP-5.2.6, and extract the package.
tar xjf php-5.2.6.tar.bz2
Then move to the expanded directory and execute the following commands.
export LIBTOOLIZE=glibtoolize MACOSX_DEPLOYMENT_TARGET=10.5
Now we need to compile and install the extension.
MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS="-arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch x86_64 -g -Os -pipe" CXXFLAGS="-arch x86_64 -g -Os -pipe" LDFLAGS="-arch x86_64 -bind_at_load" ./configure
sudo make install
Now the extension has been compiled and installed, but you’ll probably need to do some more configuration before it will work.
Edit your php.ini, which is located in /private/etc/php.ini
Change the ‘extension_dir’ to ‘/usr/lib/php/extensions’ and enable the extension by adding this line ‘extension=soap.so’
Create a symbolic link to the soap extension
sudo ln -s /usr/lib/php/extensions/no-debug-non-zts-20060613/soap.so /usr/lib/php/extensions/soap.so
And finally restart apache for the changes to take effect
sudo apachectl restart
That’s it! you can now use the SOAP extensions.
Please let me know if you have any comments or problems with this.