Skip to content

Instantly share code, notes, and snippets.

@bazilio91
Last active October 4, 2016 19:31
Show Gist options
  • Save bazilio91/6229656 to your computer and use it in GitHub Desktop.
Save bazilio91/6229656 to your computer and use it in GitHub Desktop.
Homebrew php & php-fpm fast switch
#!/bin/bash
# php switch for homebrew
# $ brew tap josegonzalez/php && brew install php54 --with-fpm && brew install php55 --with-fpm
# Note:
# error_log = /usr/local/var/log/php-fpm.log
# and
# daemonize = yes
# must be in php-fpm.conf
VERSION_FILE="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/php-switch.version"
brew unlink php54
brew unlink php55
if [[ ! -f $VERSION_FILE ]]; then
echo "5.5" > $VERSION_FILE
fi
version=`cat $VERSION_FILE`
killall php-fpm
if [[ $version == 5.4 ]]; then
ln -sf `brew link php55`
export PATH="$(brew --prefix josegonzalez/php/php55)/bin:$PATH"
php-fpm -D --fpm-config `brew info php55 | grep etc | head -1 | sed 's/php.ini/php-fpm.conf/'`
echo "Switched to 5.5"
echo "5.5" > $VERSION_FILE
else
ln -sf `brew link php54`
export PATH="$(brew --prefix josegonzalez/php/php54)/bin:$PATH"
php-fpm --fpm-config `brew info php54 | grep etc | head -1 | sed 's/php.ini/php-fpm.conf/'`
echo "Switched to 5.4"
echo "5.4" > $VERSION_FILE
fi
echo `php -v`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment