Skip to content

Instantly share code, notes, and snippets.

@c3mdigital
Last active December 15, 2015 03:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save c3mdigital/5192074 to your computer and use it in GitHub Desktop.
Save c3mdigital/5192074 to your computer and use it in GitHub Desktop.
Bash script to start, stop and reload local installed servers.
!/bin/bash
#This bash script controls starting and stopping the homebrew installed Nginx, PHP-FPM and MySql servers
start=start
stop=stop
restart=restart
status=status
echo server $1 executed..
if [ $1 == $start ]; then
echo "Starting servers..."
sudo nginx
launchctl load -w ~/Library/LaunchAgents/homebrew-php.josegonzalez.php53.plist
mysql.server start
memcached -d -p 11211
memcached -h | grep 'memcached 1'
echo "Nginx, PHP-FPM, Memcached and MySql now running..."
elif [ $1 == $stop ]; then
echo "Stopping servers...."
sudo nginx -s stop
launchctl unload -w ~/Library/LaunchAgents/homebrew-php.josegonzalez.php53.plist
mysql.server stop
killall memcached
echo "Nginx, PHP-FPM, Memcached and MySql are now stopped..."
elif [ $1 == $restart ]; then
echo "Restarting servers...."
sudo nginx -s stop
launchctl unload -w ~/Library/LaunchAgents/homebrew-php.josegonzalez.php53.plist
killall memcached
mysql.server stop
echo "Nginx, PHP-FPM, and MySql are now stopped..."
echo "Restarting servers..."
sudo nginx
launchctl load -w ~/Library/LaunchAgents/homebrew-php.josegonzalez.php53.plist
mysql.server start
memcached -d -p 11211
memcached -h | grep 'memcached 1'
echo "Nginx, PHP-FPM, and MySql now running..."
elif [ $1 == $status ]; then
mysql.server status
php -v
nginx -v
memcached -h | grep 'memcached 1'
else
echo "Please enter a command [start|restart|stop|status]"
fi
@c3mdigital
Copy link
Author

Based on brew server installation detailed here, http://xig.me/osx-php-mysql-nginx.html.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment