Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
OSX PHP Homebrew Setup

install php

with mysql pgsql intl support

$ brew install php --with-apache --with-mysql --with-pgsql --with-intl

set php timezone in php ini

date.timezone = Europe/Vienna

load php module in apache

in /private/etc/apache2/httpd.conf add

LoadModule php5_module $FULLPATH/

fix pear permissions and config

$ chmod -R ug+w /usr/local/Cellar/php/5.3.10/lib/php
$ pear config-set php_ini /usr/local/etc/php.ini

install mysql

$ brew install mysql

install mysql default tables

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

set mysql up to start automatically on system boot:

$ mkdir -p ~/Library/LaunchAgents
$ cp /usr/local/Cellar/mysql/5.5.10/com.mysql.mysqld.plist ~/Library/LaunchAgents/
$ launchctl load -w ~/Library/LaunchAgents/com.mysql.mysqld.plist

Start mysql:

$ mysql.server start

install postgresql

$ brew install postgresql

initialize the DB

initdb /usr/local/var/postgres

add startup items

cp /usr/local/Cellar/postgresql/9.0.1/org.postgresql.postgres.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/org.postgresql.postgres.plist

start Postgres

pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

install xdebug & apc

if you don't have autoconf (Xcode 4.3) install autoconf

$ brew install autoconf 

$ pecl installxdebug apc

xdebug setup

and change


xdebug.remote_enable = On
xdebug.remote_autostart = 1

install pear packages

php q/a tools

$ pear config-set auto_discover 1
$ pear install

this will install:

PHP_Depend, PHP_CodeSniffer, File_Iterator Text_Template, PHP_Timer, YAML, Console_CommandLine, Log, PHP_TokenStream, Base, PHP_PMD, PHP_CodeBrowser, PHP_CodeCoverage, PHPUnit_MockObject, ConsoleTools, PHPUnit, phpcpd, phploc, phpqatools

install phing

$ pear channel-discover
$ pear config-set preferred_state beta
$ pear install phing/phing
$ pear config-set preferred_state stable



This comment has been minimized.

Copy link

jwigal commented Nov 25, 2013

@gxela you need to specify the specific version of php. like this:

brew install php54


brew install php 55

This comment has been minimized.

Copy link

silvenon commented Jan 16, 2014

Where do I setup this xdebug stuff?


This comment has been minimized.

Copy link

leegee commented Mar 5, 2014

If php is not included in httpd.conf, won't the user need to add AddType application/x-httpd-php .php ?


This comment has been minimized.

Copy link

GabLeRoux commented Apr 3, 2014

I had troubles with php56 and httpd installing with brew, I managed to get php working with apache by including a php.conf:

# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages.
<IfModule prefork.c>
  LoadModule php5_module modules/
<IfModule worker.c>
  LoadModule php5_module modules/

# Cause the PHP interpreter to handle files with a .php extension.
AddHandler php5-script .php
AddType text/html .php

# Add index.php to the list of files that will be served as directory
# indexes.
DirectoryIndex index.php

# Uncomment the following line to allow PHP to pretty-print .phps
# files as PHP source code:
#AddType application/x-httpd-php-source .phps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.