I wanted to thank you for the great tickets to the game. Obviously all of my clients were very happy.
HOWTO: Setup PHP, Apache and MySQL development environment on OS X Snow Leopard
UPDATED: Updated to use PHP 5.3.1 and with easier instructions for fixing PHP’s iconv linking problem via Apple’s iconv.patch file.
Although Mac OS X Snow Leopard (10.6) finally comes with current versions of open source software developers use, the default setup is not enough for our needs so we’ve compiled this easy to follow guide to setting up a PHP development environment including the following:
As I mentioned, we needed to add a few things to the PHP install that Apple left out:
Setup a place for your source code
First, you need to setup a place to store all the stuff you’re going to be downloading.
Install MaxMind’s GeoLite
This optional install allows you to use PHP’s GeoIP functions to do basic IP-based location of your site’s visitors.
Add the free GeoLite City Database
Install Apache 2.2
This will install a completely separate instance of Apache 2.2 than the Apple supplied version. This way you never have to worry about a Software Update overwriting or messing up your customized setup. The best part about this method is that you can still use the Sharing Preference Pane to start and stop your version of Apache.
We will install this version of Apache 2.2 at the root level of your hard drive /apache2. If you prefer to put it elsewhere just change the --prefix= option to where you want it. You will also need to make changes in some of the other commands below, including the configuration for PHP.
In every case where we use make you will notice that we use make -j3. This specifies to use 3 jobs during the make. An easy rule of thumb is to use the number of processor cores your machine has +1. If you have a Mac Pro, you can use make -j9 throughout these instructions.
Make Your Apache Installation Play Nice With OSX
This part will allow you to stop/start your Apache using the Sharing Preference Pane. If you find that your setup doesn’t work correctly after installing an Apple Software Update or Security Update, simply repeat this section to “repair” your setup.
Add VirtualHosts to Make Your Development Easy
We prefer to have each developer use their own VirtualHost for development and we create them in the form developername.projectname.dev. If you use this method you will need to add each of these hosts to your /etc/hosts file making sure not to mess with the existing top portion of the file.
Add in yours in the following format.
You will also need to setup VirtualHosts within your Apache conf files for each one that you wish to use. Additionally, you will want to make sure to enable PHP by editing the configuration file at /apache2/conf/httpd.conf.
Uncomment the LoadModule line for PHP by changing
Then scroll to the bottom of the file and add the following:
Lastly, for development we prefer to actually use the Sites folder in our home directories to serve sites from so we will symlink it to where Apache is looking. (This won’t work well if you have multiple developers on the same machine with different user accounts.)
Fritz Stelluto pointed out that going this route may prevent CGI scripts from executing. If you need that ability you may prefer to just change the DocumentRoot in the httpd.conf.
If you’re going to be manipulating images you will probably want to install libjeg. These instructions are adapted from the instructions at Agile Animal Inc.
If you’re going to be manipulating images you will probably also want to install libpng. These instructions are also adapted from the instructions at Agile Animal Inc.
Install IMAP c-client Libraries
You will need these if you ever want to have PHP access an IMAP mailbox, such as your Gmail.
Some HOWTOs out there tell you to use make oxp, which worked on OS X Leopard (10.5), but does not work on Snow Leopard (10.6)
We will need to have some of the c-client files in a place where our PHP configure will look for them. Use a little something found over at the Forums MacBidouille.
Mcrypt/libmcrypt “allows developers to use a wide range of encryption functions, without making drastic changes to their code.”
From the gettext homepage: “The GNU `gettext' utilities are a set of tools that provides a framework to help other GNU packages produce multi-lingual messages.” These instrustions were adapted from Imthiaz Blog.
Install PHP 5.3 on Snow Leopard
Now that iconv will link properly, continue with our make.
Be a good open source user and make test and submit your results to the PHP developers. This will take about 10-15 minutes, so go grab a beer and wait.
After you have submitted your test results, finish by installing.
Add the GeoIP PECL Extension
Setup Your php.ini
Copy php.ini-development into place. Many new options and documentation have been added in PHP 5.3 so I suggest that you diff your previous version and make sure you copy over any necessary changes you have made.
You will also need to make adjsutments to your php.ini for the geoip features. In the “Dynamic Extensions” section add
In the “Module Settings” section add
While you are editing your php.ini don't forget to set your time zone. It is required with PHP 5.3. Choose a time zone from this list.
Grab a Copy of Zend Framework
If you're a Zend Framework user you may want to go ahead and put a copy of it into your PHP environment. If you’re not sure where you want to put it you should check out Sam Hennessy’s Zend Framework - “Location, Location Location!” This will install Zend Framework 1.9.7.
Install and Configure MySQL 5.1
Download and install the MySQL 5.1 package for “Mac OS X 10.5 (x86_64).” It works fine with Snow Leopard.
Do not install the Preference Pane or the StartupItem. We will control MySQL with a “more modern” LaunchDaemon.
Paste the following into that new file and save it.
All LaunchDaemons and LaunchAgents need to be owned by root.
You will probably also want to add MySQL to your PATH if it isn't already there.
Copy and paste the following.
Reload your new profile. Make sure you get that leading dot.
We will leave the MySQL configuration and copying of your old data up to you, but if this version of MySQL is newer than your last you should run mysql_upgrade.
You may also want to update the MySQL Time Zone tables. You may incur some errors during the Time Zone table upgrade, but chances are that you can safely ignore them. If you can’t then you probably know what to do to fix them.
Feedback or Questions?
If you have any feedback or questions go ahead and email them to phponsnowleopard at teamonetickets dot com and we will try to help you out.
Team One™ Tickets is a privately owned agency that buys and resells tickets on the secondary market. We are not Ticketmaster, LiveNation, StubHub or the official box office nor are we affiliated with any professional sporting organization, performer, or venue. Our ticket prices reflect the cost of obtaining premium seating and are usually sold above "face value".
NewsletterSign up for Deals!