Updated instructions are available for installing LAMP on OSX 10.7 Lion.
I’m setting up a new machine and found a great tutorial written by Josh Lockhart on getting a PHP web development environment up and running on Snow Leopard. This goes through almost everything to be up and running for a typical LAMP stack with unit testing using all of the default services.
Josh’s instructions include everything that I need except mcrypt & IMAP. Luckily Michael Gracie has provided a walk-through for installing mcrypt on Snow Leopard which involves re-compiling some things, but isn’t as tough as it first appears. A walk-through for installing IMAP support is available on activeColab (with a pre-built binary).
After getting PHP, mcrypt and IMAP going, the last step for me is setting up MySQL which has some caveats on OSX. The main problem is that the MySQL installer places the mysql.sock file in a non-standard place and so you have to either create a link or alter your php.ini file before PHP will be able to talk to MySQL. (If you get “Can’t connect to local MySQL server through socket ‘/var/mysql/mysql.sock’” or “No such file or directory” when calling mysql_connect, then this is the problem)
After completing the steps on Josh’s & Michael’s pages and running the MySQL installation package, here are the additional steps that I like to take to get my local environment configured:
display_errors = On
mysql.default_socket = /tmp/mysql.sock
date.timezone = ‘America/Chicago’
Append FollowSymLinks to the Options
Change AllowOverride to All
I also like to change the permissions on php.ini and httpd.conf to allow my user account edit permissions and create an alias to those two files somewhere easy to get to.
Installing MAMP is probably easier, but for some reason I prefer using all of the services that are pre-bundled with OSX. Also Snow Leopard includes PHP 5.3 which led me to find a couple of deprecated functions in some of our libraries.