-
Install Homebrew:
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" $ brew update $ brew install git
-
Tap the wonderful homebrew-php from https://github.com/Homebrew/homebrew-php
$ brew tap homebrew/dupes $ brew tap homebrew/versions $ brew tap homebrew/php
-
Install php with apache and mariadb
$ brew install mariadb $ brew install php56 $ brew install php56-xdebug
-
Add the following to /etc/apache2/httpd.conf
LoadModule php5_module /usr/local/opt/php56/libexec/apache2/libphp5.so
-
Add the following to /usr/local/etc/php/5.6/php.ini
date.timezone = America/New_York
-
Add the following to ~/.zshrc after the original PATH declaration:
export PATH="$(brew --prefix homebrew/php/php56)/bin:$PATH"
-
Apache 2.4 in OS X Yosemite does not enable
mod_rewrite
by default. Feel free to enable it if needed. -
Set the Apache user and group directives to your user shortname and the "admin" group. Do this in the file /etc/apache2/httpd.conf
- Restart Apache
- This allows Apache to host sites in folders other than ~/Sites
-
Make sure Apache and MariaDB are not accessible outside of your Mac
-
MariaDB
-
Pick a cnf file from /usr/local/Cellar/mariadb//<current-version#>/support-files and copy it to /usr/local/etc/my.cnf.d/
-
I used my-medium.cnf
-
Edit the my.cnf file in the [mysqld] settings area:
-
Comment out:
binary logging is required for replication log-bin=mysql-bin binary logging format - mixed recommended binlog_format=mixed bind-address=127.0.0.1
-
-
For enhanced security, you can remove the above and add the following to my.cnf in the [mysqld] settings area. This prevents any TCP/IP connections to MariaDB. This changes will require your applications support database socket connections.
skip-networking
-
Issue the following command and follow the setup instructions to your liking. You will should get prompted by the system firewall to allow or deny mysqld connections when you first start MariaDB. Deny access!
$ brew info mariadb
-
Once you have it setup, issue this commend to start the server manually:
-
mysql.server start
-
Apache
- Make sure that new vhosts only listen to 127.0.0.1. Same goes for any port.
- Block all incoming connections to /usr/sbin/httpd using the OS X Firewall settings in System Preferences
- http://clickontyler.com/virtualhostx/
- Great Mac app for maintaining Apache vhosts and /etc/hosts entries. Of course, you can do this yourself.
Thanks, I have also tried it with PostgreSQL and works fine.