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.
cd /tmp curl -O http://de3.php.net/distributions/php-5.2.6.tar.bz2 tar xjf php-5.2.6.tar.bz2
Then move to the expanded directory and execute the following commands.
cd php-5.2.6/ export LIBTOOLIZE=glibtoolize MACOSX_DEPLOYMENT_TARGET=10.5 cd ext/soap phpize
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 make 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.
[...] Wiersma over at Pagebakers has excellent instructions for building and installing the SOAP extension without having to rebuild [...]
Hi there, Eelco,
Great set of instructions and it worked beautifully for SOAP. However, I have a particular need for the wddx extension which is also missing in Leopard. I tried adaptating your instructions, replacing “soap” with “wddx” where appropriate and everything seems to have installed correctly. Only PHP is still yelling at me when I try to use wdd_deserialize().
In particular my code is:
$page = open_page(build_month_url(), $apikey);
$m = wddx_deserialize($page);
And my error is:
Fatal error: Call to undefined function wddx_deserialize() in /Users/johnhutch/Sites/napo_dev/news/events/event_list.php on line 20
Currently this code is working on my remote server. Would you happen to have any thoughts on why this might be happening in Leopard?
Thanks for any help you can offer!
Hmm It looks like I forgot something in my instructions, you also need to enable the module by adding the following to your php.ini
extension=soap.so
or
extension=wddx.so
Hope this helps
When i try php -m:
PHP Startup: Unable to load dynamic library ‘/usr/lib/php/extensions/soap.so’ – (null) in Unknown on line 0
Your soap.so was compiled without any errors?
I get similar results on “php -m”.
Do not see any errors in compile, just a warning
/tmp/php-5.2.6/ext/soap/soap.c: In function ‘deserialize_parameters’:
/tmp/php-5.2.6/ext/soap/soap.c:3344: warning: pointer targets in passing argument 1 of ‘strcmp’ differ in signedness
The soap.so got built and copied to /usr/lib/… path
php.ini is setup.
phpinfo() shows soap client and server are there.
Any suggestions on what the issue could be? Let me know if you need more info on the build. I saved the terminal session.
Hmm, on what kind of machine are you running mac os ? Are you running the 64bit version of apache?
you can check by executing ‘apachectl -V’ in your terminal.
Xserve Intel. OS 10.5.6.
apachectl -V
does show it is 64-bit.
>apachectl -V
Server version: Apache/2.2.9 (Unix)
Server built: Sep 19 2008 10:58:54
Server’s Module Magic Number: 20051115:15
Server loaded: APR 1.2.7, APR-Util 1.2.7
Compiled using: APR 1.2.7, APR-Util 1.2.7
Architecture: 64-bit
Server MPM: Prefork
threaded: no
forked: yes (variable process count)
Server compiled with….
Ok that should be fine..
Could you try to load my soap.so?
http://www.pagebakers.nl/soap.so
Replaced soap.so with your version. looks like this one loaded as php -m shows soap as one of modules. what’s the difference in your build? something in our build environment is not configured correctly? We’ll try to get our soap server and client to work now with this module. Thanks again for your quick responses. Let me know if you need other info on our server environment.
Do you have XCode installed? That’s the only thing I can think of what could be the problem. I basically run a default OS X install with latest updates and XCode.
You can download it here;
http://developer.apple.com/mac/
I was getting errors at the “phpize” step.
Error 1 was:
cp: /tmp/php-5.2.6/ext/soap/build/libtool.m4: Permission denied
cp: /tmp/php-5.2.6/ext/soap/build/shtool: Permission denied
cp: /tmp/php-5.2.6/ext/soap/build/scan_makefile_in.awk: Permission denied
Solved this buy running the phpize as sudo
sudo phpize
The next problem was
grep: /usr/include/php/main/php.h: No such file or directory
grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:
Zend Module Api No:
Zend Extension Api No:
Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF
environment variable is set correctly and then rerun this script.
I solved this by installing the xtool package on the install disc of mac osx leopard.
I thought I was out of the woods but ran into the same problem as “raman L” with the
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php/extensions/soap.so’ – (null) in Unknown on line 0
I downloaded your soap.so and replaced the one we made, and it all works….
I have the Xtools package installed. I’m on 10.5.5 with php 5.2.6 on a mac powerbook.
Hi guys,
I am having a similar problem, except I’m trying to get the GD Library installed.
My apache error log says:
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php/extensions/gd.so’ – (null) in Unknown on line 0
But the installation went off with out a hitch (swapping gd for soap). Plus, when I run “php -m” I see gd there! But phpinfo() doesn’t show it, and I tried a function to make sure.
Any ideas? I’m running 10.5.6 on an aluminum macbook, with xocde installed. Any help is GREATLY appreciated! I’ve been fighting this all night! Thanks in advance!
-John
Oh one more thing, I didn’t do the exports or the other flag thingys… should I try that? I’m not really a Unix guy… so I wasn’t sure if they made a difference or not. Thanks,
-John
You need to run the configure command with :
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”
I’m pretty sure it wont run other wise.. let me know.
I have it working from the command line, but it does not work from a browser? Any ideas?
Does it show up in phpinfo(); ?
Thank you so much for sharing. I am been working on this problem for whole days. Your post solved my problem. I also used your method to install http extension. I worked very well.
Hey there,
nice tutorial but I got some problems with it, tho.
As we do not need soap but gd, pdo_pgsql and some other extensions I was quite happy about a solution that doesn’t require to build or update PHP from scratch – as I’m not the UNIX geek.
However, following your instructions (running OSX Server 10.5.4, PHP 5.2.5, running on an old Dual 1GHz PowerPC G4 – but does the thing quite well…) I faced already a problem during the ./configure command ;(
If I phpize (it says permission denied when doing it twice?!) and run the ./configure it returns an error:
————————————————————–
checking wether the C compiler works… configure: error: cannot run C compiled programs.
If you meant to cross compile, use ‘–host’.
————————————————————–
I installed the latest Xcode (312_2621) version prior to anything. I really don’t know what I’m doing wrong here. I also tried to change the ./configure line to “-arch x86_32″ as I’m assuming that x86_64 is the 64bit version but wasn’t lucky there as well.
Any help, and I’m going to reinstall php or whatever from scratch if necessary and as long as it’s well instructed (I’m really a newbie on Unix – not on Mac OS) and doesn’t screw up the Server, is highly appreciated!!!
Thanks,
Michael
I found an almost perfect solution that works like a charm:
http://www.kyngchaos.com/software:php
Thanks,
Michael
Micheal,
Yeah.. you need to use other flags then the x86_64 flags because you’re compiling for PowerPC, glad you found a working solution!
[...] La soluzione si trova su Pagebakers: [...]
i’ve got a similar situation as Adam – library is loaded ala php -m (client), but doesn’t show in phpinfo(). any ideas?
Thanks for putting this together. It saved me a lot. However, I ran into the same problem as raman. After I used your soap.so file, everything started working fine. I never got any compile or install error. I am also running PHP 5.2.6 on Mac Leopard notebook and has intel core 2 dual.
once again, thank you for your post.
If you’re running a 32 bit cpu (Intel Core Duo, for instance), you need to use a different arch parameter:
MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS=”-arch i386 -g -Os -pipe -no-cpp-precomp” CCFLAGS=”-arch i386 -g -Os -pipe” CXXFLAGS=”-arch i386 -g -Os -pipe” LDFLAGS=”-arch i386 -bind_at_load” ./configure
Ok, I got this working. In addition to changing the -arch parameter for my 32 bit machine (use -arch i386, NOT the likely-sounding “x86_32″), I discovered that my module was named soap.so, but the php.ini file was looking for php_soap.so. I changed the name of the file, and now I’m in business.
I can’t seem to get the compile to happen. I’m running a Powerbook G4 (PPC) running Leopard 10.5.6, Apache 2 (32bit), PHP 5.2.6.
I’m using the compile command:
MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS=”-arch i386 -g -Os -pipe -no-cpp-precomp” CCFLAGS=”-arch i386 -g -Os -pipe” CXXFLAGS=”-arch i386 -g -Os -pipe” LDFLAGS=”-arch i386 -bind_at_load” ./configure
trying to compile pdo_mysql, gd, and mcrypt.
This is the response I get from the terminal:
checking for grep that handles long lines and -e… /usr/bin/grep
checking for egrep… /usr/bin/grep -E
checking for a sed that does not truncate output… /usr/bin/sed
checking for gcc… gcc
checking for C compiler default output file name… rm: a.out.dSYM: is a directory
a.out
checking whether the C compiler works… configure: error: cannot run C compiled programs.
If you meant to cross compile, use `–host’.
See `config.log’ for more details.
I’ve seen problems similar to this here in the comments, but can’t find a solution that works. I’m not sure what I’m doing wrong.
Thanks in advance for your help.
Aaron
Perhaps I should also note that Leopard is running all the latest updates and all developer tools are installed.
Looks like you need to use other flags for the configure command, try ‘ppc’ instead of i386
Thank you for all the info here – that’s twice now you’ve eased me through this process! Worked like a charm once I fixed my own typos…
Hello!
It works perfectly when I’m trying to acces my test page with some code including
$client = new SoapClient("https://test.com");
BUT! when I’m trying to run it from command line
like
php mytest.php
it gives me an error
Fatal error: Uncaught SoapFault exception: [Client] Possible integer overflow in memory allocation (3886261185 * 4 + 0) in /Users/…..
Actually I’m trying to do not web site but some script so I do need it to run from command line.
Can anyone give me any suggestions?
With kind regards.
Hi
to get a Universal Binary (this works on ppc i386 and 64bit) just use this configure command
MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS=”-arch x86_64 -arch i386 -arch ppc -g -Os -pipe -no-cpp-precomp” CCFLAGS=”-arch x86_64 -arch i386 -arch ppc -g -Os -pipe” CXXFLAGS=”-arch x86_64 -arch i386 -arch ppc -g -Os -pipe” LDFLAGS=”-arch x86_64 -arch i386 -arch ppc -bind_at_load” ./configure
after this u can look at the file and see all cpu archs ar suppoted.
file /usr/lib/php/extensions/soap.so
/usr/lib/php/extensions/soap.so: Mach-O universal binary with 3 architectures/usr/lib/php/extensions/soap.so (for architecture x86_64): Mach-O 64-bit bundle x86_64
/usr/lib/php/extensions/soap.so (for architecture i386): Mach-O bundle i386
/usr/lib/php/extensions/soap.so (for architecture ppc7400): Mach-O bundle ppc
and this is the only way i found to ruh soap on mac os x 10.5.7
After following the instructions, I see the soap information in phpinfo(), but I still get the following error in my web browser
Fatal error: Call to undefined function wddx_deserialize() in /Library/WebServer/Documents/UCserv/Documents/UC09_Signs/esri_singleSignon.php on line 374
I am running a 10.5.6 server on a ppc G4, and I have changed the configuration parameters to ppc.
Any help would be appreciated.
On Errors with:
PHP Startup: Unable to load dynamic library ‘/usr/lib/php/extensions/soap.so’ – (null) in Unknown on
This look like a Bug with the link, try to set extension_dir to /usr/lib/php/extensions/ and copy the file(!) soap.so to this directory. Restart the apache after that.
LL&P
David
Thank you, this saved me SO much time and headache!
I completed all the steps however when i run the phpinfo command soap is not support.. Running latest version of Leopard on 32bit Macbook Pro.
Works like a charm!
Installing a new PHP on top of Apples hopeless by compiling your own is a realy good idea. Unfortuately, getting GD, and often Xdebug there can be a cunt of a problem to solve. If you need these things (esp. GD and MySql support0, you might be better off just using the one at entropy.ch. Marc keeps his binaries right up to date.
Many thanks it worked !!!
small changes:
using this.
MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS=”-arch x86_64 -arch i386 -arch ppc -g -Os -pipe -no-cpp-precomp” CCFLAGS=”-arch x86_64 -arch i386 -arch ppc -g -Os -pipe” CXXFLAGS=”-arch x86_64 -arch i386 -arch ppc -g -Os -pipe” LDFLAGS=”-arch x86_64 -arch i386 -arch ppc -bind_at_load” ./configure
and works flawless on my small hackintosh :-)
[...] noticed this article that instructs you on how to install php_soap.so extension on Leopard [...]