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. 4.
  5. install XQuartz from http://xquartz.macosforge.org/
    5.
  6. ruby -e “$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)”
  7. 6.
  8. brew doctor
  9. 7.
  10. brew tap homebrew/dupes
  11. 8.
  12. brew tap josegonzalez/homebrew-php
  13. 9.
  14. brew install php54 —with-pgsql
  15. 10.
  16. brew install php54-xdebug
  17. 11.
  18. brew install mcrypt php54-mcrypt
  19. 12.
  20. sudo apachectl restart
  21. 13.
  22. vi ~/.bash_profile      
  23. 14.
  24. export PATH=“$(brew —prefix josegonzalez/php/php54)/bin:$PATH
  25. 15.
  26. sudo vi /etc/apache2/httpd.conf
  27. 16.
  28. Add after the commented LoadModule directive:
  29. ⁃ #LoadModule php5_module libexec/apache2/libphp5.so
  30. ⁃ LoadModule php5_module */usr/local/Cellar/php54/5.4.12/libexec/apache2/libphp5.so
  31. ⁃ (Note: ensure that the version you actually install from Brew matches the path)
  32. ⁃ (Note: uncomment the following: Include /private/etc/apache2/extra/httpd-vhosts.conf)
  33. 17.
  34. sudo apachectl restart
  35. 18.
  36. brew install git
  37. 19.
  38. brew install curl-ca-bundle
  39. 20.
  40. brew install autoconf automake apple-gcc42 libksba libtool pkg-config libyaml
  41. 21.
  42. brew install node
  43. 22.
  44. sudo apachectl restart
  45. 23.
  46. vi ~/.bash_profile
  47. ⁃ export PATH=“/usr/local/mysql/bin:$PATH
  48. 24.
  49. brew install mysql
  50. 25.
  51. mkdir -p ~/Library/LaunchAgents
  52. 26.
  53. ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
  54. 27.
  55. launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
  56. 28.
  57. mysql_secure_installation
  58. mysql_secure_installation
    29.
  59. mysql.server start
  60. 30.
  61. mkdir /Users/ampodobas/Sites
  62. 31.
  63. sudo vi /etc/apache2/httpd.conf
  64. 32.
  65. Ensure DocumentRoot is set to DocumentRoot “/Library/WebServer/Documents/”
  66. 33.
  67. Change “AllowOverride None” to “AllowOverride All”
  68. 34.
  69. Add the following:

* NameVirtualHost *:80

<Directory “/Users/name/Sites”>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all

ServerName localhostDocumentRoot /Library/WebServer/Documents

35.

  1. sudo apachectl restart
  2. 36.
  3. visit http://localhost in the browser
  4. 37.
  5. brew install gtk+