Last active
December 11, 2015 03:33
-
-
Save grasses/f3d660058050199aaef9 to your computer and use it in GitHub Desktop.
php-fpm controller for mac, please confirm php-fpm is in your $PATH environment.
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/sh | |
param=$1 | |
if [ $(id -u) != "0" ]; then | |
echo "Error: You must be root to run this script." | |
exit 1 | |
fi | |
start() | |
{ | |
fpms=`ps aux | grep -i "php-fpm" | grep -v grep | awk '{print $2}'` | |
if [ ! -n "$fpms" ]; then | |
sudo php-fpm | |
echo "PHP-FPM Start" | |
else | |
echo "PHP-FPM Already Start" | |
fi | |
} | |
stop() | |
{ | |
fpms=`ps aux | grep -i "php-fpm" | grep -v grep | awk '{print $2}'` | |
echo $fpms | xargs kill -9 | |
for pid in $fpms; do | |
if echo $pid | egrep -q '^[0-9]+$'; then | |
echo "PHP-FPM Pid $pid Kill" | |
else | |
echo "$pid IS Not A PHP-FPM Pid" | |
fi | |
done | |
} | |
case $param in | |
'start') | |
start;; | |
'stop') | |
stop;; | |
'restart') | |
stop | |
start;; | |
*) | |
echo "Usage: sudo php.fpm start|stop|restart";; | |
esac | |
# Installition | |
# sudo cp ./php.fpm /usr/bin/php.fpm | |
# sudo chmod +x /usr/bin/php.fpm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment