Submitted by shrop on Mon, 07/09/2012 - 4:10pm
Update: The docs below are deprecated. Please refer to these docs going forward. Also, MAMPbegone is now brewStack! Thanks to @tlattimore for providing the cool name!
I have had an on and off relationship with MAMP over the years. I love how MAMP makes it super easy to install a nice stack of web server tools in an OS X Application, but it does have its share of limitations.
- Running older version of PHP. Sometimes I would like to run a slightly newer version than is available.
- Running Apache 2.0. No Apache 2.2 love in MAMP yet.
- There isn't an easy way to add new PHP extensions. I recently needed XMLRPC and had to track down a binary from the Moodle community. Another example is intl. I needed that for some recent Symfony work.
- Pear doesn't always work out of the box without some fixes.
- While it is open source, if I have to compile much to fix MAMP, I might as well compile PHP from CLI from source as I did for years prior to using MAMP.
I do appreciate MAMP! It is great and I still recommend it for anyone who can live within its feature set and limitations. I often recommend it for new Drupal users. MAMP allows them to get started very quickly.
As I mentioned above, I have also spent a bit of my development life compiling Apache and/or PHP from source to build local development environments. This is something that I don't want to do again. So what do I want? I want to have a local development evironment with the following characteristics:
- Easy to install and configure
- Easy to upgrade
- Easy to extend (Adding new PHP extensions or upgrading PHP)
- php-cgi for use with Drush qd
- Secure
- Easy setup for virtual hosts and changes to the /etc/hosts file. I can, but don't need to spend the time configuring this by hand all the time!
- Lastly, this needs to support my Drupal and Symfony development needs! I have included some additional bits I use, such as drush and Composer.
I decided on the following tools to provide Apache, MySQL, PHP and GUI/easy eay to setup vhosts and /etc/hosts file changes:
Tools:
- OS X Lion's Apache - I can totally live with Apple's supplied Apache 2.2 server. There is no need for me to maintain this component.
- homebrew-php - This is magical! Using Homebrew to install PHP from Jose Gonzalez's repo allows me to install and run PHP 5.3, PHP 5.4, a number of standard extensions, and php-cgi. Since this is hosted on github, I can fork the repo and make my own changes and additions!
- Homebrew's MariaDB formula - You can also use MySQL if you prefer.
- VirtualHostX - I have used VirtualHostX for years with and without MAMP. It is the easiest way to manage local development Apache vhosts and the /etc/hosts file. Well worth the money!
Before we get into the install steps, I want to mention a couple of similar/realated blog posts which are worth checking out for additional options and thoughts on this process. I have tailored my install steps on what I need. You can take my post and the posts below to help develop your local development environment formula!
- OS X 10.7 Lion Development: Native Apache & PHP with Homebrew MySQL or MariaDB by Alan Ivey)
- PHP with Homebrew by John Albin
- Mac Development: Replacing MAMP in 11 easy steps by Alex Weber
Install steps:
- Install Homebrew:
$ /usr/bin/ruby -e "$(/usr/bin/curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"
$ brew install git
$ brew update
$ brew install drush - Tap the wonderful homebrew-php from https://github.com/josegonzalez/homebrew-php
$ brew tap josegonzalez/homebrew-php- Install composer for Symfony and other PHP package management
$ brew install composer- Generate php-cgi for use with drush-qd.
$ brew install php53 --without-apache --with-mariadb --with-intl --with-suhosin- Backup php-cgi and uninstall php53 since you homebrew-php will not install php-cgi and lib5php.so at the same time
$ cp /usr/local/Cellar/php53/5.3.13/bin/php-cgi ~/bin/
$ brew uninstall php53 - Install php 5.3 with apache, mariadb, intl (for Symfony 2), and suhosin patch
$ brew install php53 --with-mariadb --with-intl --with-suhosin
- Now that php 5.3 is compiled for Apache, you can copy the php-cgi binary compiled previously to ~/bin or any other bin directory in the current path.
- Add the following to /etc/apache2/httpd.conf
LoadModule php5_module /usr/local/Cellar/php53/5.3.13/libexec/apache2/libphp5.so- Install additional php extensions (Optional. Follow configuration instructions after each install.)
$ brew install php53-apc
$ brew install php53-mongo
$ brew install php53-uploadprogress
$ brew install php53-xdebug
$ brew install php53-xhprof - Set your timezone for php. I used the following in /usr/local/etc/php/5.3/php.ini.
date.timezone = America/New_York*Set the following for Symfony 2 compatibility in /usr/local/etc/php/5.3/php.ini:
detect_unicode = off- Set the Apache user and group directives to your user and group. Do this in the file /etc/apache2/httpd.conf
- Restart Apache
- This allows Apache to host sites in folders other than ~/Sites
Security:
- Make sure Apache and MariaDB are not accessible outside of your Mac
- MariaDB
- Pick a cnf file from /usr/local/Cellar/mariadb/5.3.5/share/mysql and copy it to /usr/local/etc/my.cnf
- I used my-medium.cnf
- Edit my.cnf and add the following in the [mysqld] settings area:
- MariaDB
bind-address=127.0.0.1- For enhanced security, you can remove the above and add the following to my.cnf in the [mysqld] settings area. This prevents any TCP/IP connections to MariaDB. This changes will require your applications support database socket connections.
skip-networking- Issue the following command and follow the setup instructions to your liking. You will should get prompted by the system firewall to allow or deny mysqld connections when you first start MariaDB. Deny access!
$ brew info mariadb- Once you have it setup, issue this commend to start the server manually:
- mysql.server start
- Apache
- Edit /etc/apache2/httpd.conf, replacing "listen 80" with
listen 127.0.0.1:80- Make sure that new vhosts only listen to 127.0.0.1. Same goes for any port.
VirtualHostX:
- http://clickontyler.com/virtualhostx/
- Great Mac app for maintaining Apache vhosts and /etc/hosts entries. Of course, you can do this yourself.
Update: Hey, if you do this, please tweet a link to this blog post along with hastag #MAMPbegone
Comments
Nice post... I've been using
Permalink Submitted by MrWolfpack (not verified) on Tue, 07/10/2012 - 7:54pm.
Nice post... I've been using the native Apache server in OS X for a while and am pleased with it. However, I have steered clear of CLI package management in OS X for fear of breaking something, but I am going to give Homebrew a hard look after reading this post. I'd like to be able to test different versions of PHP and MySQL and try out MariaDB in Lion and not depend on VMWare which is a resource hog for obvious reasons. Up to now, I've confined my PHP and MySQL package juggling to Ubuntu or whatever LInux distro I'm into...lately Arch.
This is good info. Thanks!
I wish I'd had this when I
Permalink Submitted by Tom Geller (not verified) on Wed, 07/11/2012 - 3:18am.
I wish I'd had this when I started out on Drupal four years ago!
But why not just use Acquia Dev Desktop (http://acquia.com/downloads)? I believe it addresses the issues that drove you to the homebrew solution in the first place.
WIth Acquia Dev Desktop, you
Permalink Submitted by shrop on Wed, 07/11/2012 - 9:30am.
WIth Acquia Dev Desktop, you could easily end up in the same place as I did with MAMP. It is a well done environment for working with local Drupal development, but as soon as you want to work with tools beyond what is provided, it may not work.
I am glad you mentioned Acquia Dev Desktop though. It is a great tool and I recommend it often at CharDUG meet ups.
Thanks for all you do to training Drupalers Tom!
LOL. Yeah, I wish this post
Permalink Submitted by MrWolfpack (not verified) on Thu, 07/12/2012 - 9:55am.
LOL. Yeah, I wish this post had been around when I started Drupaling, but I've only been Drupaling since Jan of 2011.
No worries. We all start
Permalink Submitted by shrop on Thu, 07/12/2012 - 10:01am.
No worries. We all start somewhere. :)
Reason #1: You can't use port
Permalink Submitted by Damien McKenna (not verified) on Wed, 08/15/2012 - 3:17pm.
Reason #1: You can't use port 80 or 443, i.e. the default HTTP/HTTPS ports, with Dev Desktop.
I just finished setting this
Permalink Submitted by DeeterGP (not verified) on Thu, 07/12/2012 - 3:44pm.
I just finished setting this up on my machine and importing all of my formerly-on-MAMP local dev sites into it and it is humming along nicely! Thank you for sharing this writeup, Shrop.
I think other web site
Permalink Submitted by Layanan Bisnis... (not verified) on Tue, 09/11/2012 - 5:15am.
I think other web site proprietors should take this site as an model, very clean and wonderful user friendly style and design, let alone the content. You're an expert in this topic! As I web site possessor I believe the content matter here is rattling wonderful , appreciate it for your hard workYou should keep it up forever! Bye.
Artikel lainnya silakan dilihat http://goo.gl/FbAXT & Artikel lainnya http://www.nulis.web.id/layanan-bisnis-pulsa-dan-token-pln.php & jangan lupa baca Artikel silakan dilihat lainnya http://goo.gl/sycnl sip
You need to make sure that
Permalink Submitted by Zach (not verified) on Fri, 08/03/2012 - 9:20am.
You need to make sure that you have X11 installed (http://support.apple.com/kb/HT5293) before you can compile php53. It has a dependency for libpng which has been removed from homebrew in favor of the version from X11 (http://librelist.com/browser//homebrew/2011/3/14/notice-libpng-is-being-...).
Thanks! yeah, some of us in
Permalink Submitted by shrop on Fri, 08/03/2012 - 10:11am.
Thanks! yeah, some of us in the office found this out too. We installed xquartz, which is a another way to get this issue covered. I plan on blogging about changes between the originally docs and what is needed for 10.8 to work.
Why not use a virtualbox
Permalink Submitted by Craig (not verified) on Tue, 08/07/2012 - 9:29am.
Why not use a virtualbox appliance like quickstart (http://drupal.org/project/quickstart) or drupalpro (http://drupal.org/project/drupalpro)?
I have played a bit with
Permalink Submitted by shrop on Tue, 08/07/2012 - 12:04pm.
I have played a bit with running a VM. The issue for me is that VMs take up ram, that I need for other things. The other issue is that you have to really tweak things with shared folders and host files to allow me to browse the sites and edit the code on the VM, while using my Mac tools. If you have the ram and have those other issues resolved, those certainly are alternatives.
brew install php53 --without
Permalink Submitted by Bryan Stalcup (not verified) on Tue, 09/11/2012 - 8:08am.
brew install php53 --without-apache --with-mariadb --with-intl --with-suhosin
will not work on Mountain Lion with 10.8.1 update due to zlib being removed from homebrew. zlib now ships with Mountain Lion, to handle dependencies on it, run 'brew tap homebrew/dupes', see https://github.com/josegonzalez/homebrew-php/pull/219 for discussion.
Thanks Bryan! That is exactly
Permalink Submitted by shrop on Tue, 09/11/2012 - 8:44am.
Thanks Bryan! That is exactly correct. I had that fix in my docs, but haven't updated here. Will do that today. Thanks much!
Asian Brain
Permalink Submitted by Asian Brain (not verified) on Tue, 06/18/2013 - 7:36pm.
That is very interesting Smile I love reading and I am always searching for informative information like this. This is exactly what I was looking for. Thanks for sharing this great.
Add new comment