为了账号安全,请及时绑定邮箱和手机立即绑定

PHP-FPM启动脚本

标签:
PHP


#!/bin/sh#=======================================================================================# php-fpm - this script start and stop the php-fpm daemon## chkconfig 35 on# description: php-fpm is a FastCGI web server.# processname: php-fpm# config: /usr/local/php/etc/php-fpm.conf# pidfile: /var/run/php-fpm.pid#=======================================================================================PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin    BINFILE="/usr/local/php/sbin/php-fpm"CFGFILE="/usr/local/php/etc/php-fpm.conf"PIDFILE="/var/run/php-fpm.pid"LOCKFILE="/var/lock/php-fpm.lock"    RETVAL=0    start() {    [[ -x $BINFILE ]] || exit 5    [[ -f $CFGFILE ]] || exit 6           if [[ `ps aux | grep php-fpm: | grep -v grep | wc -l` -gt 0 ]]; then        echo "The php-fpm is already running."        return 1    fi           $BINFILE -t >/dev/null 2>&1           if [[ $? -ne 0 ]]; then        echo "The php-fpm configure has error."        return 1    fi           echo -n "Starting php-fpm......"    $BINFILE -y $CFGFILE -g ${PIDFILE}    RETVAL=$?    echo    [[ $RETVAL -eq 0 ]] && touch $LOCKFILE           return $RETVAL}    stop() {    if [[ `ps aux | grep php-fpm: | grep -v grep | wc -l` -eq 0 ]]; then        echo "The php-fpm is not running."        return 1    fi           echo -n "Shutting down php-fpm......"           if [[ -f $PIDFILE ]]; then        kill -QUIT `cat ${PIDFILE}`    else        kill -QUIT `ps aux | grep php-fpm | awk '/master/{print $2}'`    fi           RETVAL=$?    echo    [[ $RETVAL -eq 0 ]] && rm -f $LOCKFILE $PIDFILE           return $RETVAL}    restart() {    stop    sleep 1           while true    do        if [[ `ps aux | grep php-fpm: | grep -v grep | wc -l` -eq 0 ]]; then            start            break        fi        sleep 1    done           RETVAL=$?    echo           return $RETVAL}    reload() {    if [[ `ps aux | grep php-fpm: | grep -v grep | wc -l` -eq 0 ]]; then        echo "The php-fpm is not running."        return 1    fi           echo -n $"Reloading php-fpm......"           if [[ -f $PIDFILE ]]; then        kill -USR2 `cat ${PIDFILE}`    else        kill -USR2 `ps aux | grep php-fpm | awk '/master/{print $2}'`    fi           RETVAL=$?    echo           return $RETVAL}    case "$1" instart)    start    ;;       stop)    stop    ;;       restart)    restart    ;;       reload)    reload    ;;       *)    echo "Usage: service php-fpm {start|stop|restart|reload}"    RETVAL=1esac    exit $RETVAL


点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消