gorn.ch

Tobias Ebnöther's personal blog

Leopard native apache with custom (64bit) PHP

With massive! help from Marc Ammann I was able to build a PHP Binary that loads with the Leopard shipped Apache.

First I got iconv source from apple and took the libiconv/include/iconv.h.build.in file. It seems that apple uses different headers in the build process than installed. So the build headers use precompiler flags that gcc doesn't know (it's most likely some sort of XCode stuff which I don't know anything about). After removing that stuff the file looks like this.

With this file as a replacement for /usr/include/iconv.h PHP will build with CFLAGS='-arch x86_64' and load with the native apache afterwards. It's even possible to build the pecl memcache extension like that (but don't forget the right arch).

For completion that were my configure flags:
CFLAGS='-arch x86_64' ./configure \
'--with-zlib' \
'--with-apxs2=/usr/sbin/apxs' \
'--prefix=/usr/local/php5' \
'--with-iconv' \
'--with-xsl' \
'--disable-xmlreader' \
'--with-jpeg-dir' \
'--with-png-dir=' \
'--enable-bcmath' \
'--with-curl' \
'--with-ldap' \
'--enable-mbstring' \
'--enable-soap'
Related Entries:
Leopard PHP / Apache Package with pecl support
xchat on OSX / Command as alt
Setting up relayhost for postfix on OSX (with ssl and authentication)
Jackalope presentation and status
MacHeist Software Bundle
Comments (8)  Permalink

Comments

What is Apache? @ 24.11.2007 13:37 CEST
Why use the Leopard Apache when regular Apache is available? If you are developing locally for deployment on a server, wouldn't you want the same setup on the local machine as on the public server?
mike @ 18.01.2008 16:18 CEST
i'm still having issues compiling php after replacing the iconv.h file, is there a way to restore the iconv.h back to the original? do you have the original source?
ebi @ 18.01.2008 16:24 CEST
It seems like it got more complicated with 10.5.1.

Currently I'm using the beta package from entropy which is available in the forum. My future way will be to build the whole thing (including apache) and pack them into rpm. (I will port pure-build [a "packge manager we used in pure-linux.sf.net] to osx to get nicely removeable packages).

Here is the iconv.h that came shipped with my Leopard (probably afer installing updates): http://trash.gorn.ch/orig_iconv.h
david windham @ 25.01.2008 19:45 CEST
i think i may need you're help..
similar situation on a G5..
ebi @ 25.01.2008 21:07 CEST
Theoretically it should work with "-arch ppc64" instead of x86_64. But I never compiled PHP on my old G5 (that I don't have anymore) so I can't help you much there.
Mike @ 06.08.2008 16:58 CEST
didn't work for me - i got a bunch of link errors: "_libiconv", referenced from:
__php_iconv_appendl in iconv.o
__php_iconv_appendl in iconv.o
...
ebi @ 06.08.2008 17:04 CEST
It unfortunately may not work on newer Leopard installations. Also I got one report that it only works ONCE with a fresh unpacked PHP bundle (even make distclean didn't help that guy).

I didn't try out this for a while since I switched back to the PHP Bundle from Marc (http://entropy.ch) which is available as Beta from the Forums.

If you still want to build it yourself you can try to link it against the libiconv in /Developer but it will only run on machines with XCode installed.
pete @ 17.03.2009 19:47 CEST
This iconv PHP Leopard thing has been driving people crazy all over the world from what I can see.

However...I think I'm onto the definitive solution: the problem is at least partly the fault of the PHP configure file.

In configures test for iconv, it runs a little C programme that does an iconv_open. Unfortunately, the call looks all wrong. iconv_open expects two character set parameters (const * char). These HAVE to be in the list of valid codes (you can see that by running iconv -l). PHP's C code calls iconv_open with two random character strings. Because these are not valid charsets, the call fails...and iconv fails configure. Change this call in configure to something like:
cd = iconv_open("UTF-8","ISO-8859-1") and the call will succeed. Voila - configure continues!!

Hopefully this solution will get out to those who want a roll-your-own PHP on Leopard.
No new comments allowed (anymore) on this post.
Powered by Flux CMS