Skip to content

Instantly share code, notes, and snippets.

@jessedc
Last active September 28, 2017 22:13
Show Gist options
  • Save jessedc/3488335 to your computer and use it in GitHub Desktop.
Save jessedc/3488335 to your computer and use it in GitHub Desktop.
PHP setup instructions OSX 1.8 Mountain Lion

Setting up PHP on Mountain Lion from scratch

Editing text files from the command line is made easier with TextMate with it's command line extension mate OR Sublime text2 with command line extensions. However the built in nano text editor is easy to use as well.

Some guidance gleaned form from coolestguyplanettech.com

Change permissions on /Library/WebServer/Documents so all users can write to it

sudo chmod -R o+w /Library/WebServer/Documents

(Optional) Place a reference to /Library/WebServer/Documents to your shortcut bar

Change some apache settings and enable php

sudo nano /etc/apache2/httpd.conf

Find the following lines

2.1. <Directory "/Library/WebServer/Documents">

A few lines down change AllowOverride None to AllowOverride All

2.2. <IfModule dir_module>

Change DirectoryIndex to index.html index.php

2.3. php

Uncomment the line starting with LoadModule php5_module ...

Edit php configuration

sudo cp /etc/php.ini.default /etc/php.ini
sudo nano /etc/php.ini

Change the following options

display_errors On
html_errors = On
date.timezone = Australia/Melbourne
mysqli.default_socket = /tmp/mysql.sock

TODO: add xdebug configuration

Install homebrew

ruby <(curl -fsSkL raw.github.com/mxcl/homebrew/go)

Install mysql

brew install mysql
mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp

Get mysql to startup on boot

change open plist and change user to root

nano /usr/local/Cellar/mysql/5.5.27/homebrew.mxcl.mysql.plist

sudo cp /usr/local/Cellar/mysql/5.5.27/homebrew.mxcl.mysql.plist /Library/LaunchAgents
sudo chown root /Library/LaunchAgents/homebrew.mxcl.mysql.plist
sudo launchctl load /Library/LaunchAgents/homebrew.mxcl.mysql.plist

mysql.server start

/usr/local/Cellar/mysql/5.5.27/bin/mysqladmin -u root password 'root'

Download Sequel Pro OR Install PHPMyAdmin

PhpMyAdmin installation to be completed... it's a bit of a pita

mv `phpma` and move to `/Library/WebServer/Documents`
mv ~/Downloads/phpma/ /Library/WebServer/Documents
mate /Library/WebServer/Documents/phpma
mkdir /Library/WebServer/phpma/config
chmod 777 /Library/WebServer/phpma/config

Setting up from absolute scratch, or older machines

  1. Run a software update on your machines and install everything that needs to be updated
  2. Set a password for your current admin account on your machine
  3. Install Xcode and SourceTree from the App Store
  4. Open Xcode and go to it's settings and go to the 'Downloads' section and install the download the Command Line Tools
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment