Skip to content

Instantly share code, notes, and snippets.

@deekayen
Forked from shrop/brewStack.md
Last active August 9, 2017 15:23
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save deekayen/77caa6a87c9d285beb10 to your computer and use it in GitHub Desktop.
Save deekayen/77caa6a87c9d285beb10 to your computer and use it in GitHub Desktop.
Localhost Drupal environment setup with Homebrew on Mac OS X

brewStack update for fresh install

Install steps:

  • 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

Security:

  • 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

VirtualHostX:

Copy link

ghost commented Aug 22, 2016

Thanks, I have also tried it with PostgreSQL and works fine.

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