Install homebrew, nginx, mysql, php55, and composer on Mac OS X
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# install homebrew | |
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
# install homebrew's official php tap | |
brew tap josegonzalez/homebrew-php | |
# install homebrew's official nginx tap | |
brew tap homebrew/nginx | |
# install nginx + geoip + upload progress | |
brew install nginx-full --with-geoip --with-upload-progress-module | |
# install mysql | |
brew install mysql | |
# install php 5.5 + apcu + mcrypt + opcache + solr + xdebug | |
brew install --with-fpm --with-mysql php55 | |
brew install php55-apcu php55-mcrypt php55-solr php55-xdebug | |
# install composer globally | |
curl -sS https://getcomposer.org/installer | php | |
mv composer.phar /usr/local/bin/composer | |
# set up mysql to run as user account | |
unset TMPDIR | |
mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp | |
# launch mysql on startup | |
cp `brew --prefix mysql`/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/ | |
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist | |
# launch php-fpm on startup | |
ln -sfv /usr/local/opt/php55/*.plist ~/Library/LaunchAgents | |
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.php55.plist | |
# launch nginx at startup as root (in order to listen on privileged port 80): | |
sudo cp `brew --prefix nginx`/homebrew.mxcl.nginx.plist /Library/LaunchDaemons/ | |
sudo sed -i -e 's/`whoami`/root/g' `brew --prefix nginx`/homebrew.mxcl.nginx.plist | |
sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.nginx.plist | |
echo " | |
POST-INSTALL PROCEDURE: | |
======================= | |
1) configure intellij / netbeans / phpstorm / eclipse pdt to connect to xdebug on port 9009 | |
" |
Thanks @MFRWDesign, this script hasn't been updated in awhile.
sudo rm -rf /usr/local/var/mysql
before mysql_install_db
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FYI: I didn't need the step of running mysql_install_db after installing mysql with brew. Homebrew took care of it for me; you might want to exclude the step from your script.
○ → brew install mysql
==> Installing dependencies for mysql: openssl
==> Installing mysql dependency: openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2d_1.bottle.tar.gz
################################################################## 100.0%
==> Pouring openssl-1.0.2d_1.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
/usr/local/etc/openssl/certs
and run
/usr/local/opt/openssl/bin/c_rehash
This formula is keg-only, which means it was not symlinked into /usr/local.
Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries
Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:
==> Summary
/usr/local/Cellar/openssl/1.0.2d_1: 464 files, 18M
==> Installing mysql
==> Downloading https://homebrew.bintray.com/bottles/mysql-5.6.27.bottle.tar.gz
################################################################## 100.0%
==> Pouring mysql-5.6.27.bottle.tar.gz
==> /usr/local/Cellar/mysql/5.6.27/bin/mysql_install_db --verbose --user=FakeUserName --basedir=/usr/local/Cellar/mysql/5.6.27 --datadir=/usr/local/var/mysql --tmpdir=/tmp
==> Caveats
A "/etc/my.cnf" from another install may interfere with a Homebrew-built
server starting up correctly.
To connect:
mysql -uroot
To have launchd start mysql at login:
ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
Then to load mysql now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
Or, if you don't want/need launchctl, you can just run:
mysql.server start
==> Summary
/usr/local/Cellar/mysql/5.6.27: 9884 files, 339M