MNMP + Memcached

#!/bin/bash # install homebrew's official php tap brew tap josegonzalez/homebrew-php # install homebrew-dupes (required to install zlib, php53's dependency) brew tap homebrew/dupes # install nginx + mysql + php 5.3 + php-fpm + apc + xdebug brew install nginx mysql brew install --with-fpm --with-mysql php53 brew install php53-zenddebugger php53-memcache php53-gearman php53-apc php53-mcrypt brew install memcached # add apc + xdebug configs to php.ini: if `grep -q zenddebugger /usr/local/etc/php/5.3/php.ini` then echo "The PHP config file is edited" else echo " [apc] extension = \"`brew --prefix php53-apc`/apc.so\" apc.enabled = 1 apc.shm_segments = 1 apc.shm_size = 64M apc.ttl = 7200 apc.user_ttl = 7200 apc.num_files_hint = 1024 apc.mmap_file_mask = /tmp/apc.XXXXXX apc.enable_cli = 1 [zenddebugger] zend_extension = \"`brew --prefix php53-zenddebugger`/zenddebugger.so\" " >> /usr/local/etc/php/5.3/php.ini fi # set up mysql to run as user account # install mysql db default if [ ! -d /usr/local/var/mysql ]; then unset TMPDIR rm -R /usr/local/var/mysql/* -y mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" \ --datadir=/usr/local/var/mysql --tmpdir=/tmp fi # launch mysql on startup echo "Launch MySql" if [ -f ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist ]; then launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist fi cp `brew --prefix mysql`/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/ if [ -f /tmp/mysql.sock ]; then /usr/local/bin/mysqladmin -uroot shutdown fi launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist # launch php-fpm on startup echo "Launch PHP-FPM" if [ -f ~/Library/LaunchAgents/homebrew-php.josegonzalez.php53.plist ]; then launchctl unload -w ~/Library/LaunchAgents/homebrew-php.josegonzalez.php53.plist rm ~/Library/LaunchAgents/homebrew-php.josegonzalez.php53.plist fi cp `brew --prefix php53`/homebrew-php.josegonzalez.php53.plist ~/Library/LaunchAgents/ launchctl load -w ~/Library/LaunchAgents/homebrew-php.josegonzalez.php53.plist # launch nginx at startup as root (in order to listen on privileged port 80): echo "Launch Nginx" if [ -f ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist ]; then launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist rm ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist fi cp `brew --prefix nginx`/homebrew.mxcl.nginx.plist ~/Library/LaunchAgents/ sed -i -e 's/`whoami`/root/g' `brew --prefix nginx`/homebrew.mxcl.nginx.plist launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist # launch memcached echo "Launch Memcached" if [ -f ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist ]; then launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist rm ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist fi cp `brew --prefix memcached`/homebrew.mxcl.memcached.plist ~/Library/LaunchAgents/ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist echo " POST-INSTALL PROCEDURE: ======================= 1) configure intellij / netbeans / phpstorm / eclipse pdt to connect to xdebug on port 9009 "