Skip to content

Instantly share code, notes, and snippets.

@dgrebb
Last active August 29, 2015 14:04
Show Gist options
  • Save dgrebb/435e96ab7e747ef9aad5 to your computer and use it in GitHub Desktop.
Save dgrebb/435e96ab7e747ef9aad5 to your computer and use it in GitHub Desktop.
Installs and sets up homebrew, apache, mysql, and php on a mac.
#!/bin/bash
# installs and sets up homebrew, apache, mysql, and php on a mac
echo ''
echo 'Installing and configuring Homebrew.'
echo ''
# install homebrew
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
echo ''
echo 'Checking system and updating Homebrew.'
echo ''
# set up homebrew
brew doctor
brew update
brew upgrade
echo ''
echo 'Installing PHP.'
# tap some brew and install php
brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/homebrew-php
brew install php55
echo ''
echo 'PHP successfully installed.'
echo ''
# create php.ini from default if it doesn't exist
if [ ! -f /etc/php.ini ]; then
sudo cp /etc/php.ini.default /etc/php.ini
echo 'Copying a new php.ini as you don'\''t have one yet.'
fi
echo ''
echo 'Setting PHP timezone.'
echo ''
# append date.timezone line to php.ini
sudo sed -i '' '$ a\
date.timezone = "America/New_York"
' /etc/php.ini
# install mysql
brew install mysql
echo ''
echo 'MySQL installed.'
echo ''
# set mysql to start at login
ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
# start or restart mysql
mysql.server stop
mysql.server start
# make apache use the php 5 module
echo 'Setting Apache up for php5 module.'
echo ''
sudo sed -i '' 's,#LoadModule php5_module libexec/apache2/libphp5.so,LoadModule php5_module libexec/apache2/libphp5.so,g' /etc/apache2/httpd.conf
# make apache include the virtual hosts file
echo 'Adding Apache virtual hosts include.'
echo ''
sudo sed -i '' 's,#Include /private/etc/apache2/extra/httpd-vhosts.conf,Include /private/etc/apache2/extra/httpd-vhosts.conf,g' /etc/apache2/httpd.conf
echo ''
echo 'Restarting Apache...'
echo ''
# restart apache
sudo apachectl restart
echo ''
echo 'Configuration complete.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment