Moving Away from MAMP and into Homebrew
So one of the most annoying things I ran into the PECL support from MAMP. This means no easy external extention setups for you. It also means those php.h
headers that you need to compile against PHP with does not exist either. Don’t get me wrong, MAMP is a really awesome startup to help you get your environment running but it doesn’t nearly reach the point of having a barebone, compiled version on your Mac.
Steps
First thing you need to do is have Homebrew setup. If you don’t know what Homebrew is, shame on you. It’s basically a package manager for your Mac for external tools that are useful for your computer or Terminal. Remember that Homebrew requires Xcode, which is a free application in the Mac App Store, so go get that first!
Next, make sure Homebrew is setup properly, you can easily check by running brew doctor
. It’ll even tell you how to fix things if it finds problems.
After, we need to “tap” some external Homebrew repositories, specifically the ones related to PHP. To do so run the following commands.
Once that is done, we will need to install PHP using Homebrew. It has a couple of compilation flags, so follow carefully!
Note that when it is finished installing it will throw out some things you need to do. Make sure you do it! Or else you may have some problems in the future.
Now it’s time to place PHP into Mac’s version of Apache. To do so, we need to edit the file /etc/apache2/httpd.conf
and add the following line.
Last but not least for Apache, we need to enable it through Settings->Sharing->Web Sharing
. When that’s on, Apache’s config file will be loaded and be placed as a process. You can now run sudo apachectl restart
restart, stop, and start the server.
You can also edit the file /etc/apache2/httpd.conf
to enable any of the modules that it already has. I specifically like enabling “Virtual Hosts” so maybe you should too! An example of my /etc/apache2/extra/httpd-vhosts.conf
looks something like this.
Remember how I had this post to get Mongo adapter working? Well, it’s so much more simple now! All you need to do is run.
Note you may need to edit /usr/local/etc/php/5.3/php.ini
and add this line to get it working.
Last but not least, we need MySQL. Really easy with Homebrew, just run the following lines and follow its instructions.
Done! You should now have a full MAMP setup, with out the MAMP :).