This guide is for compiling a web development environment in OS X. There are easier methods (and faster) to set up a development environment — such as Homebrew, MacPorts, Fink — but none provide the control I was looking for. These instructions were made for Mountain Lion but should be fairly similar for previous versions of OS X.
Start with the Getting Started section, then proceed with installing your desired packages. Some packages need to be installed in a certain order to satisfy dependencies. Each package lists its dependencies at the beginning of the instructions.
Source Code Management
PHP served by Apache
Ruby served by Pow
Warning: Remember that these instructions are for creating a development environment and therefore security is not considered. For a production system, please refer to each product's respective documentation on how to properly secure each service.