Skip to main content

Mac OS X - Local Web Development Environment Setup

My name is Alex Podobas and I’m a member of the UCLA IT Security Office. My IT security work at UCLA involves an ample amount of code review and writing web applications and I use OS X as my primary, day-to-day operating system. Recently, I wiped my computer and decided to use Homebrew as my package and dependency manager to re-install and customize my LAMP-stack (I suppose minus the “L” in that acronym), local environment for web development. The steps below will take you from a fresh install of OS X to having a running web server on your local machine in about an hour.

Notes:

1. Be sure to replace “ampodobas” with your own OS X username. To find out that username, open Terminal (Applications/Utilities/Terminal) and type “whoami”

2. I make no guarantees, warranties, representations that executing the instructions below will work as stated. I merely am echoing what worked for me.

  1. open Terminal (Applications/Utilities/Terminal)
  2. install Xcode (https://developer.apple.com/xcode/)
  3. install Xcode’s Command Line tools for Xcode (Google search for this link)
  4. install XQuartz from http://xquartz.macosforge.org/
  5. ruby -e “$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)”
  6. brew doctor
  7. brew tap homebrew/dupes
  8. brew tap josegonzalez/homebrew-php
  9. brew install php54 —with-pgsql
  10. brew install php54-xdebug
  11. brew install mcrypt php54-mcrypt
  12. brew install gtk+
  13. sudo apachectl restart
  14. vi ~/.bash_profile      
  15. export PATH=“$(brew —prefix josegonzalez/php/php54)/bin:$PATH
  16. sudo vi /etc/apache2/httpd.conf
  17. Add after the commented LoadModule directive:
  18. ⁃ #LoadModule php5_module libexec/apache2/libphp5.so
  19. ⁃ LoadModule php5_module */usr/local/Cellar/php54/5.4.12/libexec/apache2/libphp5.so
  20. ⁃ (Note: ensure that the version you actually install from Brew matches the path)
  21. ⁃ (Note: uncomment the following: Include /private/etc/apache2/extra/httpd-vhosts.conf)
  22. sudo apachectl restart
  23. brew install git
  24. brew install curl-ca-bundle
  25. brew install autoconf automake apple-gcc42 libksba libtool pkg-config libyaml
  26. brew install node
  27. sudo apachectl restart
  28. vi ~/.bash_profile
  29. ⁃ export PATH=“/usr/local/mysql/bin:$PATH
  30. brew install mysql
  31. mkdir -p ~/Library/LaunchAgents
  32. ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
  33. launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
  34. mysql_secure_installation
  35. mysql.server start
  36. mkdir /Users/ampodobas/Sites
  37. sudo vi /etc/apache2/httpd.conf
  38. Ensure DocumentRoot is set to DocumentRoot “/Library/WebServer/Documents/”
  39. Change “AllowOverride None” to “AllowOverride All”
  40. Add the following (this web posting doesn’t really allow spaces and breaks) and then run " sudo apachectl restart"
  • NameVirtualHost *:80
  • <Directory “/Users/name/Sites”>
    * Options Indexes FollowSymLinks MultiViews
    * AllowOverride All
    * Order allow,deny
    * Allow from all
    *

  • * ServerName localhost
    * DocumentRoot /Library/WebServer/Documents
    *