Skip to content

Instantly share code, notes, and snippets.

@sampotts
Created October 26, 2016 07:08
Show Gist options
  • Save sampotts/b640a7b343d059c794d3744614297fc3 to your computer and use it in GitHub Desktop.
Save sampotts/b640a7b343d059c794d3744614297fc3 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Tips
# http://derickbailey.com/2014/12/27/how-to-start-nginx-on-port-80-at-mac-osx-boot-up-log-in/
# https://gist.github.com/ogrrd/5824274
# http://stackoverflow.com/questions/16002268/prevent-nginx-504-gateway-timeout-using-php-set-time-limit
# http://serverfault.com/questions/189940/how-do-you-restart-php-fpm
PHP_VERSION='56';
DOT_VERSION='5.6';
GIST='https://gist.githubusercontent.com/SamPotts/3d40d439fe1b37302d6c/raw';
echo '---- Add Repositories ----'
brew tap homebrew/homebrew-php
brew update
echo '---- MYSQL -----'
brew install mysql
mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
echo 'Setting up launch mysql at boot'
ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents/l
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
echo '---- NGINX ----'
brew install nginx
echo 'Download nginx configs....'
mkdir /usr/local/etc/nginx/{common,sites}
curl -Lo /usr/local/etc/nginx/nginx.conf ${GIST}/d2ef1268ffb83222b8731f7e98099acad94575a9/nginx.conf
curl -Lo /usr/local/etc/nginx/common/php ${GIST}/75a570e632158815e19772edbd4336844ee3a19b/php
# Download Virtual Hosts.
curl -Lo /usr/local/etc/nginx/sites/default ${GIST}/14725b6a471debe3efc0f49edcb2f4a97c1e4362/default
echo 'Setting up launch nginx at boot'
sudo cp /usr/local/opt/nginx/*.plist /Library/LaunchDaemons/
sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
# Create folder for logs.
rm -rf /usr/local/var/log/{fpm,nginx}
mkdir -p /usr/local/var/log/{fpm,nginx}
echo '---- PHP + FPM ----'
brew install freetype jpeg libpng gd
brew install php${PHP_VERSION} --without-apache --with-mysql --with-fpm --without-snmp
brew link --overwrite php${PHP_VERSION}
echo 'Setting up launch PHP at boot'
ln -sfv /usr/local/opt/php${PHP_VERSION}/*.plist ~/Library/LaunchAgents/
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.php${PHP_VERSION}.plist
echo 'Done! You should run `/usr/local/opt/mysql/bin/mysql_secure_installation` now'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment