views:

10217

answers:

7

Can anyone direct me to or write their experiences installing Apache and PHP on Snow Leopard?

I had this working in the past on Leopard, it would die after a security update, but was as simple as:

$ ./configure --enable-layout=Darwin --enable-mods-shared=all
$ make
$ sudo make install

and I was up and running again.

Since the Snow Leopard update I get the following issue on make command

libtool: link: cannot find the library `/usr/lib/libexpat.la' or unhandled argument `/usr/lib/libexpat.la'
make[2]: *** [htpasswd] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all-recursive] Error 1
A: 

Mac OS X Snow Leopard already comes with Apache 2.2 and PHP 5.3 pre-installed. Please see:

http://www.brandonsavage.net/first-glance-apples-snow-leopard/

It is probably best to leave those alone, as they are optimally configured for Snow Leopard.

Michael Aaron Safyan
Thank you Michael, I am aware that these are installed by default, I prefer the compile from source method.
ricbax
A: 

Well if you have no need for a custom built version of PHP than perhaps the one Apple provides will do, but that is not the case, with the person who asked the question, or me for that matter as I seek an answer to the same question. Does anyone else have a suggestion?

Hi Alan, did you find any solutions to this yet?
ricbax
+2  A: 

As most of you know Snow Leopard (SL) is based on 64-bit architecture, and when you install Xcode 3.2 that comes with SL the gcc compiler defaults to 4.2.1 and seems to default to x86_64 not i386.

Thanks to the following websites:

My Solution:

  1. Follow the instructions on hivelogic.com for installing MySQL on SL

  2. Install Apache 2.2.14 via instructions on http://projects.serenity.de/php/ - it uses 2.2.13 but replacing a 13 with a 14 is easy right? ;) After Apache (x86_64) is installed do the following:

    cd /usr/local/apache2/bin
    cp httpd /usr/sbin/
    cp apachectl /usr/sbin/
    

    As mentioned on http://www.kevinkorb.com/post/24

  3. Compile and install packages (freetype,gettext,libjpeg,libpng,mcrypt,mhash,etc) mentioned right after the Apache install instructions on http://projects.serenity.de/php/ until IMAP, if you need IMAP then try the instructions mentioned in the url above but I didn't install since I didn't need it.

    NOTE: These all compiled as x86_64 with the exception of libpng which required the the following to be compiled as 64-bit:

    *export CFLAGS="-arch x86_64" ./configure

  4. This is where all the head banging on a desk and trial and error occurred. The installation of PHP 5.3.0. The biggest issue is with ICONV which has linking issues. I searched all over Google and some others were successful by editing the iconv.c file and the Makefile by adding -lresolv to the EXTRA_LIBS= after the ./configure string was executed. I was not so lucky, but still needed to make the edits for the --without-iconv parameter to work. Also --with-xmlrpc would not work. For the iconv hacks please refer to this blog entry

So here is my ./configure string:

./configure 
--prefix=/usr/local/php5
--without-iconv
--with-apxs2=/usr/local/apache2/bin/apxs
--enable-pdo
--with-gd 
--with-zlib 
--with-jpeg-dir=/usr/local 
--with-png-dir=/usr/local 
--with-libxml-dir=/usr/local 
--with-curl 
--with-mcrypt 
--with-pdo-mysql=/usr/local/mysql 
--with-mysqli=/usr/local/mysql/bin/mysql_config 
--with-mysql=/usr/local/mysql 
--with-mhash 
--with-libxml-dir=/usr/local 
--with-t1lib=/usr/local 
--with-xsl 
--with-freetype-dir=/usr/local 
--with-gettext 
--with-bz2=/usr 
--with-openssl=/usr 
--enable-bcmath 
--enable-calendar 
--enable-cgi 
--enable-exif 
--enable-ftp 
--enable-gd-native-ttf 
--enable-mbstring 
--enable-soap 
--enable-sqlite-utf8 
--enable-cli 
--enable-wddx 
--enable-zip

make
sudo make install


On a final note, I downloaded PHP-5.3.2-dev (http://snaps.php.net/) and it seems to have fixed the linking issues with ICONV and XMLRPC. The only changes that I've made to the above ./configure string were replace --without-iconv with --with-iconv=/usr/local and added --with-xmlrpc. This is a dev version and I am sure that it still has bugs so use at your own discretion.

If you are having any issues please feel free to comment and I will try to help!

ricbax
A: 

Can anybody tell me why my fresh Snow Leopard install does NOT have php/apache installed? I do not have php in my usr/bin/ dir or any of the apache files either! What's also weird is i have the option to enable web sharing in sys prefs.

landis
sorry, obvious newbie here. I just discovered Text Wrangler (www.barebones.com) and suddenly it's all so clear!
landis
A: 

Maybe you didnt install the developer tools!

Marian
Xcode is installed
ricbax
A: 

I'm having the same issue ("unhandled argument") when running make for apache on SL. I don't see the instructions for compiling Apache at http://projects.serenity.de/php/ - did they go away maybe?

(For Apache) I actually used the old instructions which are now located here: http://articles.serenity.de/compiling_php_with_oracle_leopard/
ricbax
ricbax:Thanks for the link. I actually solved the problem by first re-installing Apache from the SL Disc first using Pacifist.Rob
+2  A: 

Hi,

See here: http://bugs.php.net/bug.php?id=49267

Basically:

  1. Add "-lresolv" to MH_BUNDLE_FLAGS, EXTRA_LDFLAGS and EXTRA_LDFLAGS_PROGRAM in "Makefile"

  2. Change "ext/iconv/iconv.c"

    #define iconv libiconv

    to:

    #define iconv iconv

As they say, worked for me.

Jess Portnoy