Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save zapatoche/8530b0221451455223a1a3830cc001a2 to your computer and use it in GitHub Desktop.
Save zapatoche/8530b0221451455223a1a3830cc001a2 to your computer and use it in GitHub Desktop.
Installing NGINX+PHP+MYSQL+DNSMASQ+NVM+NODE+NPM in OSX "El Capitan"
#!bash
# Removing apache from autostart
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
brew tap homebrew/services
# Installing NGINX
brew install nginx
# Adding NGINX to autostart
sudo cp /usr/local/opt/nginx/*.plist /Library/LaunchAgents
sudo launchctl load -w /Library/LaunchAgents/homebrew.mxcl.nginx.plist
brew tap homebrew/dupes
brew tap homebrew/homebrew-php
brew tap homebrew/versions
# Installing PHP
xcode-select --install
brew install -v php55 --with-debug --without-apache --with-fpm --with-mysql
brew install php55-mcrypt
# Setting timezone and change other PHP settings
(export USERHOME=$(dscl . -read /Users/`whoami` NFSHomeDirectory | awk -F"\: " '{print $2}') ; sed -i '-default' -e 's|^;\(date\.timezone[[:space:]]*=\).*|\1 \"'$(sudo systemsetup -gettimezone|awk -F"\: " '{print $2}')'\"|; s|^\(memory_limit[[:space:]]*=\).*|\1 512M|; s|^\(post_max_size[[:space:]]*=\).*|\1 200M|; s|^\(upload_max_filesize[[:space:]]*=\).*|\1 100M|; s|^\(default_socket_timeout[[:space:]]*=\).*|\1 600|; s|^\(max_execution_time[[:space:]]*=\).*|\1 300|; s|^\(max_input_time[[:space:]]*=\).*|\1 600|; $a\'$'\n''\'$'\n''; PHP Error log\'$'\n''error_log = '$USERHOME'/Sites/logs/php-error_log'$'\n' $(brew --prefix)/etc/php/5.5/php.ini)
export PATH=/usr/local/sbin:${PATH}
# Installing MySQL
brew install -v homebrew/versions/mysql56
# Enable MySQL
mysql.server restart
# Adding NGINX to autostart
ln -sfv /usr/local/opt/mysql56/*.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql56.plist
# Configure MySQL
mysql_secure_installation
# Making all .dev request respond with localhost
brew install dnsmasq
echo 'address=/.dev/127.0.0.1' > /usr/local/etc/dnsmasq.conf
# Adding DNSMASQ to autostart
sudo cp -fv /usr/local/opt/dnsmasq/*.plist /Library/LaunchDaemons
sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
# IMPORTANT, you need to add the follow IP to DNS Settings
# 127.0.0.1
# 8.8.8.8
# 4.4.4.4
brew unlink node
brew install nvm
mkdir ~/.nvm
echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.bash_profile
echo '. "$(brew --prefix nvm)/nvm.sh"' >> ~/.bash_profile
. ~/.bash_profile
nvm install 5.6.0
# closing terminal window / reopening should result in:
node --version # == v5.6.0
npm install -g npm@latest
brew install mongo
brew install redis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment