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.
- 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)
- install XQuartz from http://xquartz.macosforge.org/
5. - ruby -e “$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)”
- brew doctor
- brew tap homebrew/dupes
- brew tap josegonzalez/homebrew-php
- brew install php54 —with-pgsql
- brew install php54-xdebug
- brew install mcrypt php54-mcrypt
- sudo apachectl restart
- vi ~/.bash_profile
- export PATH=“$(brew —prefix josegonzalez/php/php54)/bin:$PATH”
- sudo vi /etc/apache2/httpd.conf
- 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)
- sudo apachectl restart
- brew install git
- brew install curl-ca-bundle
- brew install autoconf automake apple-gcc42 libksba libtool pkg-config libyaml
- brew install node
- sudo apachectl restart
- vi ~/.bash_profile
- ⁃ export PATH=“/usr/local/mysql/bin:$PATH”
- brew install mysql
- mkdir -p ~/Library/LaunchAgents
- ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
- launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
- mysql_secure_installation
- mysql.server start
- mkdir /Users/ampodobas/Sites
- sudo vi /etc/apache2/httpd.conf
- Ensure DocumentRoot is set to DocumentRoot “/Library/WebServer/Documents/”
- Change “AllowOverride None” to “AllowOverride All”
- 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
- visit http://localhost in the browser
- brew install gtk+