Skip to content

Instantly share code, notes, and snippets.

@nesbert
Last active October 10, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nesbert/3702744 to your computer and use it in GitHub Desktop.
Save nesbert/3702744 to your computer and use it in GitHub Desktop.
Basic info to set up a new Mac for PHP development.

New Mac Set Up

Apps & Utilities

  1. Alfred (http://www.alfredapp.com/)
  2. Dropbox (http://db.tt/rUwqOa8)
  3. Codebox (http://www.codeboxapp.com/)
  4. Sublime Text 2 (http://www.sublimetext.com/2)
  5. Sequel Pro (http://www.sequelpro.com/)
  6. Chrome (http://www.google.com/chrome)
  7. Firefox (http://getfirefox.com)
    • firebug
    • YSlow
    • Firecookies

Optional

  • IntelliJ IDEA
  • 1Password

Getting Started

The following guide will help you set-up your new machine for PHP development:

  • Apache Web Server 2.2.x with mod rewrite enabled
  • MySQL 5.5.x
  • PHP 5.3.x

Note the following guide was created on Mac OS X and with a user named "nhidalgo".

Install Xcode 4.x

Make sure your OS X version is up to date. Download Xcode (https://developer.apple.com/xcode/) and install the "Command Line Tools".

Install MySQL 5.5.x

MySQL (http://www.mysql.com/downloads/mysql/)

Install Homebrew

Go to http://mxcl.github.com/homebrew/.

$ brew tap homebrew/dupes
$ brew update
$ brew install wget
$ brew install autoconf

PHP 5.3

Common PHP modules for DEV: apc, bcmath, bz2, calendar, Core, ctype, curl, date, dom, ereg, exif, fileinfo, filter, ftp, gd, gettext, hash, iconv, imap, intl, json, ldap, libxml, mbstring, mcrypt, memcache, memcached, mhash, mongo, mysql, mysqli, mysqlnd, OAuth, odbc, openssl, pcntl, pcre, PDO, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, phalcon, Phar, posix, Reflection, session, shmop, SimpleXML, soap, sockets, solr, SPL, SQLite, sqlite3, standard, sysvmsg, sysvsem, sysvshm, tokenizer, uploadprogress, wddx, xhprof, xml, xmlreader, xmlrpc, xmlwriter, xsl, zip, zlib.

$ brew tap josegonzalez/homebrew-php
$ brew options php53
$ brew install php53
$ brew install php53-apc
$ brew install php53-mcrypt
$ brew install php53-memcache
$ brew install php53-memcached
$ brew install php53-mongo
$ brew install php53-redis

Add .bashrc, .bash_profile, .vimrc

~/.bashrc

# PATH sample 
PATH=/usr/local/bin:/usr/local/php5/bin:/usr/local/mysql/bin:$PATH

~/.bash_profile

# Load bashrc
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

~/.vimrc

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" General
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

set nocompatible                  " Must come first because it changes other options.

set showcmd                       " Display incomplete commands.
set showmode                      " Display the mode you're in.

syntax enable                     " Turn on syntax highlighting.
filetype plugin indent on         " Turn on file type detection.

set backspace=indent,eol,start    " Intuitive backspacing.

set hidden                        " Handle multiple buffers better.

set wildmenu                      " Enhanced command line completion.
set wildmode=list:longest         " Complete files like a shell.

set ignorecase                    " Case-insensitive searching.
set smartcase                     " But case-sensitive if expression contains a capital letter.

set number                        " Show line numbers.
set ruler                         " Show cursor position.

set incsearch                     " Highlight matches as you type.
set hlsearch                      " Highlight matches.

set wrap                          " Turn on line wrapping.
set scrolloff=3                   " Show 3 lines of context around the cursor.

set title                         " Set the terminal's title

set visualbell                    " No beeping.

set nobackup                      " Don't make a backup before overwriting a file.
set nowritebackup                 " And again.
set backupdir=~/tmp               " Set backup directory.
set noswapfile                    " Don't make swap files.
set directory=$HOME/.vim/tmp//,.  " Keep swap files in one location.

set laststatus=2                  " Show the status line all the time

Apache Server (/etc/apache2)

Set Apache Server's configuration file (/etc/apache2/httpd.conf). We will do the follow:

  • Change DocumentRoot to ~/Sites (http://localhost)
  • Enable virtual hosts
  • Add default and a new vhost (*optional)

$ sudo vi /etc/apache2/httpd.conf

...

# User home directories
Include /private/etc/apache2/extra/httpd-userdir.conf

# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf

...

$ sudo vi /etc/apache2/users/nhidalgo.conf

# Override Default DocumentRoot
DocumentRoot "/Users/nhidalgo/Sites"

<Directory "/Users/nhidalgo/Sites">
   Options Indexes FollowSymLinks MultiViews
   AllowOverride All
   Order allow,deny
   Allow from all
</Directory>

$ sudo vi /etc/apache2/extra/httpd-vhosts.conf

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
NameVirtualHost *:443

#
# Virtual hosts (Custom)
#
Include /etc/apache2/vhosts.d/*.conf

$ sudo mkdir /etc/apache2/vhosts.d $ sudo vi /etc/apache2/vhosts.d/_default_.conf

<VirtualHost _default_:80 _default_:443>
    DocumentRoot "/Users/nhidalgo/Sites"
    ServerName localhost
</VirtualHost>

Sample Virtual Host

$ sudo vi /etc/apache2/vhosts.d/creovel.dev.conf

<VirtualHost *:80>
    DocumentRoot "/Users/nhidalgo/Sites/creovel.dev/public"
    ServerName creovel.dev
    ServerAlias www.creovel.dev
    ErrorLog "/etc/apache2/creovel.dev-error.log"
    CustomLog "/etc/apache2/creovel.dev-access.log" common
</VirtualHost>

$ sudo vi /etc/hosts ; add a host for each new vhost

127.0.0.1       creovel.dev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment