Skip to content

Instantly share code, notes, and snippets.

@niepi
Created February 28, 2012 13:23
Show Gist options
  • Star 71 You must be signed in to star a gist
  • Fork 20 You must be signed in to fork a gist
  • Save niepi/1932534 to your computer and use it in GitHub Desktop.
Save niepi/1932534 to your computer and use it in GitHub Desktop.
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/libphp5.so

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

extension=xdebug.so


to

zend_extension="$fullpath/xdebug.so"
xdebug.remote_enable = On
xdebug.remote_autostart = 1

install pear packages

php q/a tools

$ pear config-set auto_discover 1
$ pear install pear.phpqatools.org/phpqatools pear.netpirates.net/phpDox

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.phing.info
$ pear config-set preferred_state beta
$ pear install phing/phing
$ pear config-set preferred_state stable

resources

@jwigal
Copy link

jwigal commented Nov 25, 2013

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

brew install php54

or

brew install php 55

@silvenon
Copy link

Where do I setup this xdebug stuff?

@leegee
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 ?

@GabLeRoux
Copy link

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/libphp5.so
</IfModule>
<IfModule worker.c>
  LoadModule php5_module modules/libphp5-zts.so
</IfModule>

#
# 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