Skip to content

Instantly share code, notes, and snippets.

@Ky1e
Forked from pwenzel/lamp-stack-osx-virtualhostx.md
Last active January 25, 2016 17:20
Show Gist options
  • Save Ky1e/893afb65aa504c2c2fdb to your computer and use it in GitHub Desktop.
Save Ky1e/893afb65aa504c2c2fdb to your computer and use it in GitHub Desktop.
LAMP stack on OSX with Homebrew, built-in Apache, multiple PHP versions, VirtualhostX optional

Run the following Homebrew commands to install PHP and MySQL

brew update
brew install php56
brew install php56-mcrypt
brew install mysql
mysql.server start

Test and configure PHP

  • Run /usr/local/Cellar/php56/5.6.0/bin/php --version → should yield PHP 5.6.0 (cli)
  • edit ~/.bash_profile or ~/.config/fish/fish.config
  • add the line alias php='/usr/local/Cellar/php56/5.6.0/bin/php'
  • Run php --version → should yield PHP 5.6.0 (cli)

VirtualHostX

Configure VirtualHostX to use Built-in Apache instead of MAMP.

Create a new site with custom virtual host directives:

LoadModule php5_module /usr/local/Cellar/php56/5.6.0/libexec/apache2/libphp5.so
AddType application/x-httpd-php .php
DirectoryIndex index.html index.htm index.php

MySQL

With a MySQL client such as Sequel Pro, connect to MySQL at localhost with the username root and no password.

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