mac下编写php-fpm管理脚本

本文介绍了一种在本地环境中通过源码编译安装PHP,并使用自定义脚本来管理PHP-FPM进程的方法。包括启动、停止、重启和重载配置等功能,为用户提供了一个灵活且高效的PHP运行环境。

php源码编译安装后,自己使用命令管理脚本。

DESC="php-fpm daemon"
NAME=php-fpm
# PHP安装路径
INSTALL_PATH=/usr/local/php/7.1
# php-fpm路径
DAEMON=$INSTALL_PATH/sbin/$NAME
# 配置文件路径
CONFIGFILE=$INSTALL_PATH/etc/$NAME.conf
# PID文件路径(在php-fpm.conf设置)
PIDFILE=$INSTALL_PATH/var/run/$NAME.pid

SCRIPTNAME=$INSTALL_PATH/sbin/$NAME

# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0

rh_start() {
  $DAEMON -y $CONFIGFILE || echo -n " already running"
}

rh_stop() {
  kill -QUIT `cat $PIDFILE` || echo -n " not running"
}

rh_reload() {
  kill -HUP `cat $PIDFILE` || echo -n " can't reload"
}

case "$1" in
  start)
        echo "Starting $DESC: $NAME"
        rh_start
        #echo "\n"
        ;;
  stop)
        echo "Stopping $DESC: $NAME"
        rh_stop
        #echo "\n"
        ;;
  reload)
        echo "Reloading $DESC configuration..."
        rh_reload
        echo "reloaded."
  ;;
  restart)
        echo "Restarting $DESC: $NAME"
        rh_stop
        sleep 1
        rh_start
        #echo "\n"
        ;;
  *)
         echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" >&2
         exit 3
        ;;
esac
exit 0
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值