Skip to content

Instantly share code, notes, and snippets.

@shrop
Last active October 11, 2023 20:18
Show Gist options
  • Save shrop/3698170 to your computer and use it in GitHub Desktop.
Save shrop/3698170 to your computer and use it in GitHub Desktop.
brewStack Docs

brewStack update for fresh install

Install steps:

  • Install Homebrew:

    • Follow the install instructions found on this page.
  • Tap the wonderful homebrew-php from https://github.com/Homebrew/homebrew-php

      $ brew tap homebrew-php
    
  • Install php with apache and mariadb

      $ brew install mariadb  
      $ brew install php55   
    
  • Add the following to /etc/apache2/httpd.conf

      LoadModule php5_module /usr/local/opt/php55/libexec/apache2/libphp5.so
    
  • 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 staff 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

Additional setup

  • Helpful bit for your .zshrc to include homebew-php binaries to the system path

      PATH="$(brew --prefix  homebrew/php/php55)/bin:$PATH"
    
  • For large databases, you may need to incrase the max_allowed_packet size in my.cnf to something like the example below:

      max_allowed_packet=1024M
    

VirtualHostX:

@tlattimore
Copy link

It looks like on Yosemite mod_rewrite isn't enabled by default (I seem to remember it being before but could be wrong). This is a requirement for a number of PHP applications. It can be enabled by uncommenting line 168 of /etc/apache2/httpd.conf.

@shrop
Copy link
Author

shrop commented Oct 26, 2014

@tlattimore: I had the same issue. I will make sure to note that in the docs. Thanks!

@deetergp
Copy link

Looks good @shrop! I'd recommend changing the tap named homebrew/homebrew-php to just homebrew/php.

@shrop
Copy link
Author

shrop commented Oct 30, 2014

Thanks @deetergp, made the change.

@deetergp
Copy link

May want to change the group in httpd.conf to "staff" rather than admin. I ran into issues with Apache not restarting properly when I had it set to "admin".

Also might want to consider bumping max_allowed_packet up to 1026M in my.cnf.

@shrop
Copy link
Author

shrop commented Mar 6, 2015

Thanks for all the suggestions. I think they are all implemented. I did some overall readability improvements also.

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