On my previous article, I’ve discussed two ways to enable PHP on your Mac. For most situation, one of those two solutions should be sufficient. There are times, however, that you need more features than the default and therefore need to customize one or more components of your MAMP stack.
For me, the need comes when I need PCNTL extension for my PHP-CLI scripts. Unfortunately, both of those solutions doesn’t have PHP with PCNTL support. So I’m forced to recompile PHP on either MAMP package or the built-in PHP.
My initial tendency is to not touch whatever built-in with Mac OS X as they may have upgrades later and the custom changes may conflict with the official update. It’s also possible that you inadvertently install the update that overwrite the custom changes you made. However, I could not find the original configuration parameters for MAMP package. Thus, I’m forced to update PHP built-in with Mac OS X.
So having quite lengthy introduction, which I feel is needed for you to understand the background reasoning of why I’m rebuilding MAMP stack by recompiling packages from scratch on Mac OS X 10.5 Leopard.
Before continuing, you need to make sure XCode is installed. If you have the installation DVD, browse through optional install folder to find XCode. Alternatively, you can download XCode from Apple. You need to get a free apple developer membership to download from Apple. Install XCode with the default options and you should be fine.
Secondly, you need to be comfortable working with command line and understand the basics of compiling open source programs; those are to configure the source (usually ./configure), then to compile (by running make) it, then to install it (by running make install).
Configure script takes different options for each software. In general configure script will take –prefix option. This option specifies the location where the software will be installed. It also takes –help to list all options that can be set.
First, install MySQL
There are 2 ways to install MySQL on Mac OS X. You can download the appropriate package from MySQL download page, or you can compile MySQL from scratch. My tendency is to not compile MySQL from scratch as MySQL team usually does a very good job on their binaries. This time, however, I’d suggest for you to compile MySQL from scratch. For some reasons the binary version of MySQL doesn’t have enough file to compile PHP with MySQL support.
So for this time, download the source code. Here’s a cleaned-up copy of my session when compiling MySQL. If you want to follow my steps verbatim, follow this instruction to install wget for Mac OS X.
user:~ user$ mkdir compile user:~ user$ cd compile user:compile user$ wget http://dev.mysql.com/get/Downloads/MySQL-5.1/ \ > mysql-5.1.34.tar.gz/from/http://mysql.he.net/ user:compile user$ tar -zxvf mysql-5.1.34.tar.gz user:compile user$ cd mysql-5.1.34 user:mysql-5.1.34 user$ ./configure --prefix=/usr/local/mysql user:mysql-5.1.34 user$ make user:mysql-5.1.34 user$ sudo make install
Notes on my session compiling MySQL on Mac OS X
- You can add more options to ./configure depending on what you need. Do pass –help to get all the options.
- On the last step when you’re installing, do provide your password if asked.
- The easiest way to make sure MySQL starts when your computer starts, you can dowload MySQL binary package and install MYSQLStartupItem.pkg. To save you from downloading the large binary, you can download it here. Once installed, then issue the following command to start MySQL:
user:~ user$ sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
On the next page, we’ll discuss on how to compile and install default Apache that comes with Mac OS X.