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)
- install Xcode (https://developer.apple.com/xcode/)
- 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. sudo apachectl restart
13. vi ~/.bash_profile
14. export PATH=“$(brew —prefix josegonzalez/php/php54)/bin:$PATH”
15. sudo vi /etc/apache2/httpd.conf
16. Add after the commented LoadModule directive:
⁃ #LoadModule php5_module libexec/apache2/libphp5.so
⁃ LoadModule php5_module /usr/local/Cellar/php54/5.4.12/libexec/apache2/libphp5.so
⁃ (Note: ensure that the version you actually install from Brew matches the path)
⁃ (Note: uncomment the following: Include /private/etc/apache2/extra/httpd-vhosts.conf)
17. sudo apachectl restart
18. brew install git
19. brew install curl-ca-bundle
20. brew install autoconf automake apple-gcc42 libksba libtool pkg-config libyaml
21. brew install node
22. sudo apachectl restart
23. vi ~/.bash_profile
⁃ export PATH=“/usr/local/mysql/bin:$PATH”
24. brew install mysql
25. mkdir -p ~/Library/LaunchAgents
26. ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
27. launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
28. mysql_secure_installation
29. mysql.server start
30. mkdir /Users/ampodobas/Sites
31. sudo vi /etc/apache2/httpd.conf
32. Ensure DocumentRoot is set to DocumentRoot “/Library/WebServer/Documents/”
33. Change “AllowOverride None” to “AllowOverride All”
34. Add the following:
NameVirtualHost *:80
<Directory “/Users/name/Sites”>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
35. sudo apachectl restart
36. visit http://localhost in the browser
37. brew install gtk+