PHP and apache are included on Mac OSX but there are a few things you need to set it up. This setup is also needed after upgrading to Yosemite, for some reason the update removed all these config settings.

EDIT HTTPD.CONF AND PHP.INI

  • edit httpd.conf
$ sudo vim /etc/apache2/httpd.conf
  • update DocumentRoot and add a Directory Block for your Dev

DocumentRoot “/Users/[username]/Dev”

<Directory "/Users/[username]/Dev">
DirectoryIndex index.html index.htm index.php
Options FollowSymLinks Multiviews Indexes
MultiviewsMatch Any
AllowOverride All
Require all granted
</Directory>

Uncomment some modules

LoadModule rewrite_module libexec/apache2/mod_rewrite.so
LoadModule php5_module libexec/apache2/libphp5.so
  • save httpd.conf

  • copy php.ini

$ sudo cp /etc/php.ini.default /etc/php.ini
  • change permissions and edit php.ini
$ sudo chmod 755 /etc/php.ini
$ sudo vim /etc/php.ini
  • change errors and open tags
    display_errors = On
    short_open_tags = On

  • save php.ini

  • restart apache

$ sudo apachectl graceful
  • verify apache is running
    http://localhost

INSTALL PEAR AND PECL

http://jason.pureconcepts.net/2012/10/install-pear-pecl-mac-os-x/

$ curl -O http://pear.php.net/go-pear.phar 
$ sudo php -d detect_unicode=0 go-pear.phar 
# option 1
$ /usr/local/pear
# option 4
$ /usr/local/bin

See more at: http://jason.pureconcepts.net/2012/10/install-pear-pecl-mac-os-x/#sthash.eEinfHrc.dpuf

  • may need
$ brew install automake
  • install mongo

If you are running El-Capitan you will need to run csrutil disable from the recovery terminal before running pecl install.

https://www.quora.com/How-do-I-turn-off-the-rootless-in-OS-X-El-Capitan-10-11?share=1

$ sudo pecl install mongo

# if you get php.h not found install xcode command line tools
$ xcode-select --install

# if you get an error about autoconf
$ brew install autoconf
  • add to php.ini under Dynamic extensions
    extension=mongo.so

  • restart apache

$ sudo apachectl graceful
  • install mongodb
$ brew install mongo
  • Update Apache Bench
$ curl -O http://apache.mirrors.pair.com/httpd/httpd-2.4.10.tar.gz

$ brew install pcre

$ sudo ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.9.xctoolchain

$ tar xzvf httpd-2.4.2.tar.gz
$ cd httpd-2.4.2/
$ ./configure
$ make

$ sudo cp support/ab /usr/sbin