You’ll need:
In this tutorial, we’re going to be operating out of ~/work (the “work” subdirectory of your Home folder). Whenever we say “download x.y.z.tar.gz”, we assume you download it and put it in that folder. If you’re downloading using your favourite web browser, it usually places them in ~/Downloads. So, to move “x.y.z.tar.gz” to ~/work, you can usually just type:
$ mv ~/Downloads/x.y.z.tar.gz ~/work
Prepare a cup of coffee or three, and put a DVD on, because you’re going to be watching your computer compile software a lot.
Start Terminal.app and type:
$ mkdir work
$ cd work
I went to dev.mysql.com/downloads and Downloaded mysql-5.1.41-osx10.5-x86_64.dmg for “Mac OS X (package format) 10.5 (x86_64)”.
After the .dmg has finished downloading, just mount and run the installer.
Download (and put in ~/work):
These are all trivial to compile and install:
$ tar xfz libevent-1.4.13-stable.tar.gz
$ cd libevent-1.4.13-stable
$ ./configure && make && sudo make install
$ cd ..
$ tar xfz memcached-1.4.3tar.gz
$ cd memcached-1.4.3
$ ./configure && make && sudo make install
$ cd ..
$ tar xfz libmemcached-0.35.tar.gz
$ cd libmemcached-0.35
$ ./configure && make && sudo make install
Although Mac OS X comes with a pretty comprehensive version of OpenSSL, I always like to compile the latest into my AMP libraries.
Download openssl-0.9.8l.tar.gz from openssl.org
$ tar xfz openssl-0.9.8l.tar.gz
$ cd openssl-0.9.8l
$ ./config && make && make test && sudo make install
Download curl-7.19.7.tar.gz from curl.haxx.se
$ tar xfz curl-7.19.7.tar.gz
$ cd curl-7.19.7
$ ./configure --with-ssl=/usr/local/ssl --enable-thread
$ make && sudo make install
Download:
And here we goooooo:
$ tar xfj freetype-2.3.11.tar.bz2
$ cd freetype-2.3.11
$ ./configure && make && sudo make install
$ cd ..
$ tar xfz libpng-1.2.40-no-config.tar.gz
$ cd libpng-1.2.40-no-config
$ cp scripts/makefile.darwin Makefile
$ make && sudo make install
$ cd ..
$ tar xfz jpegsrc.v6b.tar.gz
$ cd jpeg-6b
$ ./configure && make && sudo make install
$ cd ..
$ tar xfz tiff-3.8.2.tar.gz
$ cd tiff-3.8.2
$ ./configure && make && sudo make install
$ cd ..
$ tar xfj ImageMagick-6.5.7-9.tar.bz2
$ cd ImageMagick-6.5.7-9
$ ./configure && make && sudo make install
Download libssh2-1.2.2.tar.gz from libssh2.org.
$ tar xfz libssh2-1.2.2.tar.gz
$ cd libssh2-.1.2.2
$ ./configure && make && sudo make install
Download httpd-2.2.14.tar.bz2 from httpd.apache.org
$ tar xfj httpd-2.2.14.tar.bz2
$ cd httpd-2.2.14
$ ./configure --enable-rewrite --enable-so --enable-deflate
$ make && sudo make install
We’re going to build PHP with the following extensions in it:
You’ll need to go to pecl.php.net and download:
Now, download PHP 5.3.1. from php.net
Get ready to patch your PHP to handle some changes in Snow Leopard:
Copy the following into a file called “patch” — Remember where you put this (i.e. ~/work/patch):
--- php-5.3.0/ext/iconv/iconv.c 2009-03-16 22:31:04.000000000 -0700
+++ php/ext/iconv/iconv.c 2009-07-15 14:40:09.000000000 -0700
@@ -51,9 +51,6 @@
#include
The next thing we have to do is add the PECL extensions into PHP:
$ tar xfj php-5.3.1.tar.bz2
$ cd php-5.3.1/ext/iconv
# if it asks you what file to patch, just say "iconv.c"
$ patch -p1 < ~/work/patch # or whatever path you used for the patch file
$ cd ..
$ tar xfz ../../APC-3.1.3p1.tgz
$ mv APC-3.1.3p1 apc
$ tar xfz ../../imagick-2.3.0.tgz
$ mv imagick-2.3.0 imagick
$ tar xfz ../../memcache-2.2.5.tgz
$ mv memcache-2.2.5 memcache
$ tar xfz ../../memcached-1.0.0.tgz
$ mv memcached-1.0.0 memcached
$ tar xfz ../../ssh2-0.11.0.tgz
$ mv ssh2-0.11.0 ssh2
$ cd ..
$ rm configure
$ ./buildconf --force #(it's okay to ignore the warnings here)
$ ./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs \
--with-mysqli=/usr/local/mysql/bin/mysql_config --enable-imagick \
--enable-apc --enable-soap --enable-memcache --with-zlib \
--with-openssl=/usr --enable-mbstring --enable-mbregex --with-curl \
--enable-memcached --enable-ssh2
$ make && sudo make install
Once PHP is done compiling and installing, you want to edit /usr/local/apache/conf/httpd.conf and make sure that you add the line
AddType application/x-httpd-php .php .phtml
to the section ... Also make sure that the line
LoadModule php5_module modules/libphp5.so
exists in the file too.
To start MySQL:
$ sudo /usr/local/mysql/bin/mysqld_safe --user=mysql &
To Start Apache2
$ sudo /usr/local/apache2/bin/apachectl start
And that should be it! Configure your httpd.conf and extras/httpd-vhost.conf files to reflect your development environment, and run with it! By default, your httpd document root is /usr/local/apache2/htdocs, but I almost always create various virtual hosts in ~/src/xyz.
If everything works great, you can just remove the ~/work directory and all will be cleaned up and your machine will be running a nice happy AMP stack!
Good luck!
Excellent – thanks.
Some minor issues:
You’ve written jpegsrc.v6 – but that’s not readily available. Current is:
http://ijg.org/files/jpegsrc.v7.tar.gz
The link to libpng is broken.
In libpng
$ cp scripts/makefile.darwin . # should be …
$ cp scripts/makefile.darwin makefile
I think you’re missing a “cd ..” in the section
“The next thing we have to do is add the PECL extensions into PHP:”
After patching – we’re still in iconv and need to install apc, imagick etc into ext/
Where is the htdocs directory? /usr/local/apache2/htdocs/
php is not immediately active. Is this something that needs to be configured in httpd.conf?
Hey, thanks so much for the quick proof-reading. I wrote that up late at night a few hours after I’d done the whole process
All should be fixed now, and I’ve added some extra language on “document root” as well as making sure that PHP is registered as a type for httpd.
Cheers!
marc.
Hi Marc,
I did exactly as you mentioned above but I am stuck at applying the patch. when I enter the command:
$ patch -p1 < ~/work/patch
it gives an error:
-bash: /Users/ABCD/work/patch: No such file or directory
I have no clue how I can proceed. I am first time to AMP and need help.
Thanks
Kumar
Hey Kumar!
So, you have to create a new file with the contents of that patch text above.
So, open up TextEdit.app, hit Cmd+Shift+T to go to plain text mode, and then paste in the contents of the whole patch.
When you’re done with that save it to /Users/ABCD/patch
Then you can go back to the php-5.3.1/ext/iconv directory and run the command:
$ patch -p1 < /Users/ABCD/patch
(if it asks you what file to patch, just say “iconv.c”)
That should work fine now.
Good luck building the stack!
[...] Installing AMP (Apache, MySQL, PHP) on Mac OS X 10.6 Snow Leopard [...]
How about adding PostgreSQL drivers? Any tricks with 64bit/32bit? Do we have to run Apache in 32 mode?
Rgds.
Pawel
Hey!
PostgreSQL shouldn’t be very hard. I’ve found that most of the extensions work just fine.
I haven’t fully explored the 32bit / 64bit issues with PHP. I find it a bit distressing that the language appears to just switch based on whatever platform you’re on — i can only imagine that creates problems for portability (develop on macs, deploy to 32bit linux == trouble?).
I did find that 32bit builds of MySQL didn’t run properly on Snow Leopard, but the 64bit version runs great.
I’ll do another post when I have more details.
Thanks,
marc.
Hi,
I’ve tried that and everything works fine. However I would love to have pdo support for mysql and for postgresql + mysql functions and pgsql functions. So I modified the call to configure script:
./configure –prefix=/usr/local/php5 –with-apxs2=/usr/local/apache2/bin/apxs –with-mysqli=/usr/local/mysql/bin/mysql_config –with-mysql=/usr/local/mysql/bin/mysql_config –with-pdo-mysql=/usr/local/mysql/bin/mysql_config –with-pdo-pgsql=/Library/PostgreSQL/8.4 –with-pgsql=/Library/PostgreSQL/8.4 –enable-imagick –enable-apc –enable-soap –enable-memcache –with-zlib –with-openssl=/usr –enable-mbstring –enable-mbregex –with-curl –enable-memcached –enable-ssh2
and I get following error:
Cannot find MySQL header files under /usr/local/mysql/bin/mysql_config
which is wierd. Any tips? Thanks for help. BTW it woud be helpfull because many PHP users require PDO support as it is frequently used by frameworks ex. Symfony.
Rgds.
Pawel
Okay. Sorry fro spamming but I think this might be helpful. I compiled PHP with mysql/pdo support:
./configure –prefix=/usr/local/php5 –with-apxs2=/usr/local/apache2/bin/apxs –with-mysqli=mysqlnd –with-mysql=mysqlnd –with-pdo-mysql=mysqlnd –enable-imagick –enable-apc –enable-soap –enable-memcache –with-zlib –with-openssl=/usr –enable-mbstring –enable-mbregex –with-curl –enable-memcached –enable-ssh2 –with-gd
but was unable to comile it with pdo support:
./configure –prefix=/usr/local/php5 –with-apxs2=/usr/local/apache2/bin/apxs –with-mysqli=mysqlnd –with-mysql=mysqlnd –with-pdo-mysql=mysqlnd –with-pdo-pgsql=/Library/PostgreSQL/8.4 –with-pgsql=/Library/PostgreSQL/8.4 –enable-imagick –enable-apc –enable-soap –enable-memcache –with-zlib –with-openssl=/usr –enable-mbstring –enable-mbregex –with-curl –enable-memcached –enable-ssh2 –with-gd
I receive error:
checking for PostgreSQL support for PDO… yes
checking for pg_config… /Library/PostgreSQL/8.4/bin/pg_config
checking for openssl dependencies… no
checking for PQparameterStatus in -lpq… no
Unable to build the PDO PostgreSQL driver: libpq 7.4+ is required
However I compiled PHP without PG support and planned to add it later. So I downloaded pg pdo library be pecl:
pecl download pdo_pgsql
tar xzf PDO_PGSQL-1.0.2.tgz
cd PDO_PGSQL-1.0.2
phpize
./configure –with-pdo-pgsql=/Library/PostgreSQL/8.4/bin/pg_config
make && sudi make install
and in usr/lib/php/extensions/no-debug-non-zts-20090626 I have file pdo_pgsql.so. I edited php.ini and set up extension_dir and loading this extensions:
extension=pdo_pgsql.so
and finally restarted apache. Unfortunately while trying to connect to database in php script I get error:
dyld: lazy symbol binding failed: Symbol not found: _PQconnectdb
Referenced from: /usr/lib/php/extensions/no-debug-non-zts-20090626/pdo_pgsql.so
Expected in: flat namespace
I have no idea how to solve it.
Rgds.
Pawel
Hey Pawel!
Sorry, I have very limited experience with PostgreSQL. The error message you’re getting from the configure sounds like it is finding the libpq, but just doesn’t like the version of it.
When configure stops with an error, you can go back to near the end of config.log and see what exactly happened — it always prints out the program it tried to compile and the error that caused it to stop.
See what that error message says and maybe you’ll be able to figure out what is wrong from there.
Hi Marc, Hi All,
The problem was I had 32 bit version of Postgres. The solution is to compile or download 64 bit version which you can get from: http://www.kyngchaos.com/software:postgres. After installing this version the incompatibility issue wit libpq shoul disappear and you should be able to compile php with postgres support.
Rgds. and good luck.
Pawel
P.S. Marc, thanks for the tips again — this site is very usefull.
Hey Pawel!
Thanks for posting the resolution to this. Glad to hear you solved the problem!!
Good luck,
marc.
Hi,
I have got an error at the step PHP and appropriate PECL extensions.
When I launch the
$ ./configure –prefix=/usr/local/php5 –with-apxs2=/usr/local/apache2/bin/apxs \
–with-mysqli=/usr/local/mysql/bin/mysql_config –enable-imagick \
–enable-apc –enable-soap –enable-memcache –with-zlib \
–with-openssl=/usr –enable-mbstring –enable-mbregex –with-curl \
–enable-memcached –enable-ssh2
I got something wrong with libmemcached :
checking for libmemcached location… configure: error: memcached support requires libmemcached. Use –with-libmemcached-dir= to specify the prefix where libmemcached headers and library are located
Thanks
Yannick
Does It meens i should add somthing like that ?
–with-libmemcached-dir=/usr/local/lib/
Hi again,
I found my mistake.
I have downloaded libmemcached-0.36.tar.gz instead of libmemcached-0.35.tar.gz
After using the 0.35 I have no more error.
Thanks.
Yannick.
Hello Yannick,
Yes, libmemcached is still under development, so they probably changed something in one of the functions and the memcached extension probably doesn’t know about those.
Thank you for posting about this. Hopefully other readers will see this.
Happy PHP’ing!
Hi, your article is so great. Help me a lot.
I have succesfully setup the PHP MySQL server now. But, I still have a question, I am using Windows-based Server before, in the past, I have to modify the php.ini in order to use the imap_open function in PHP.
But in Mac, where should I find, or what should I do?
Many many thx!!!
Hey Ken,
If you want to use imap_open, you have to compile PHP with the IMAP functions. To do that, you’ll have to do a bit of extra work to get the UWashington IMAP libraries compiled and installed. Check out the installation notes at http://php.net/imap, and you’ll be able to follow them to get everything going.
Good luck!
Just wondering if there is any reason (concerning 99.9% of the users) to install the apache and php, if there are fairly recent versions already included with 10.6?
I seem to be the only one having trouble installing all of this on 10.6.2.
When I try and run the configure command I get this:
“./configure: line 412: ac_fn_c_try_run: command not found”
and then a whole bunch of lines that read more or less like this:
“./configure: line 6218: 6: Bad file descriptor”
I thought I followed everything to the letter. Can anyone shed some light on what might be happening here?
Hey Nate,
This appears to be a bug in PHP’s configure script (see PHP Bug 50291 at http://bugs.php.net/bug.php?id=50291 ).
To get around it, you could either download and install an older GNU autoconf, or you could try the pure 5.3.1 tarball. I just tried that out and it worked great.
If you’re doing everything very simple and straightforward, and you’re still seeing problems, did you perhaps install some other software that required a newer autoconf or something?
Hey Mike,
For me, there are two primary reasons to roll my own AMP stacks:
For casual web development stuff, you’re right — it’s not strictly necessary. But for even the web apps I build for myself, the builtin stuff simply isn’t workable.
Cheers,
marc.
I have to admit that I am having trouble finding “the pure 5.3.1 tarball,” Marc. Do you think you could post a link? I tried both with the source from the x.tar.gz and x.tar.bz2 tarballs.
Autoconf 2.46 just doesn’t want to compile this. How can I compile it with an earlier version of autoconf?
Hi,
everything has looked good until to the point to start ./configure from php5.3.1.
Here I stuck now with the following errors.
“configure” very large, I don’t know, if this is normal.
-rwxr-xr-x 1 a staff 3060857 19 Feb 23:56 configure*
Any suggestions, what the f*** is going on here.
TIA
./configure –prefix=/usr/local/php5 –with-apxs2=/usr/local/apache2/bin/apxs \
–with-mysqli=/usr/local/mysql/bin/mysql_config –enable-imagick \
–enable-apc –enable-soap –enable-memcache –with-zlib \
–with-openssl=/usr –enable-mbstring –enable-mbregex –with-curl \
–enable-memcached –enable-ssh2
./configure: line 412: ac_fn_c_try_run: command not found
./configure: line 428: 5: Bad file descriptor
./configure: line 429: 6: Bad file descriptor
./configure: line 468: ac_fn_c_try_run: command not found
./configure: line 468: ac_fn_c_try_run: command not found
./configure: line 468: ac_fn_c_try_run: command not found
./configure: line 468: ac_fn_c_try_run: command not found
./configure: line 468: ac_fn_c_try_run: command not found
./configure: line 468: ac_fn_c_try_run: command not found
./configure: line 468: ac_fn_c_try_run: command not found
./configure: line 468: ac_fn_c_try_run: command not found
./configure: line 491: 5: Bad file descriptor
./configure: line 492: 6: Bad file descriptor
./configure: line 494: 5: Bad file descriptor
./configure: line 495: 6: Bad file descriptor
./configure: line 534: ac_fn_c_try_run: command not found
./configure: line 534: ac_fn_c_try_run: command not found
./configure: line 534: ac_fn_c_try_run: command not found
./configure: line 556: 5: Bad file descriptor
./configure: line 557: 6: Bad file descriptor
./configure: line 632: 5: Bad file descriptor
./configure: line 633: 6: Bad file descriptor
./configure: line 634: 5: Bad file descriptor
./configure: line 635: 6: Bad file descriptor
./configure: line 665: 5: Bad file descriptor
./configure: line 666: 6: Bad file descriptor
./configure: line 891: 5: Bad file descriptor
./configure: line 892: 6: Bad file descriptor
./configure: line 922: 5: Bad file descriptor
./configure: line 923: 6: Bad file descriptor
./configure: line 1223: 5: Bad file descriptor
./configure: line 1224: 6: Bad file descriptor
Uups, I’ve found it a minute later.
It was the wrong version of autoconf.
PHP need version 2.13, but I had autoconf 2.64.
Now I have installed 2.13 too and it works fine.
[...] http://adylitica.com/2009/11/24/installing-amp-apache-mysql-php-on-mac-os-x-10-6-snow-leopard/ (Bisher keine Bewertungen) 0 Kommentare [...]