Pow, Apache, Rails, WordPress, and Yosemite

I work on both PHP (WordPress) and Rails sites. It’s important that it is easy to switch contexts and manage all of the different environments. I’m constantly tweaking my dotfiles to make things easier.

I recently updated to Yosemite and ran into some issues getting Apache and Pow to play nicely along with each other. Here were my goals:

  • Run rails apps through Pow. I want to be able to visit http://myapp.dev/ and spin up my rails app
  • Visit WordPress sites on *.dev domains. I want http://wordpresssite.dev/ to render out my WordPress sites
  • PHP sites need to run on Apache for development/production parity
  • I don’t want to manually edit Apache configuration files each time I add a new site

Here’s the solution that worked for me:

  1. Install Pow. (I use powder)
  2. Set POW_DST_PORT in ~/.powconfig
  3. Manage pow rails app linking via `powder link` (for convenience)
  4. Put all WordPress sites in ~/Sites/thedomain.com
  5. Customize your Apache configuration:
    1. Remove the default php Apache configuration in /etc/apache2/other
    2. Add explicit “Require all granted” to avoid forbidden access errors with Apache 2.4
    3. Redirect all requests to http://thesite.wp.dev/ to ~/Sites/thesite.com
    4. Reverse proxy all of the remaining *.dev request to Pow