我在哪里可以找到PHP-FPM RC脚本?

前端之家收集整理的这篇文章主要介绍了我在哪里可以找到PHP-FPM RC脚本?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在自己的计算机上编译 PHP,我想知道如何设置脚本以自动启动PHP-FPM.任何人都可以建议一个脚本,为我这样做吗?我正在使用Ubuntu Linux服务器安装.
我们编译PHP时,我希望仍然有源代码.在PHP的源代码中,他们非常慷慨地包含了PHP-FPM的init脚本.您可以在< PHPsrcdir> /sapi/fpm/init.d.PHP-fpm中找到它.

您可以直接复制此文件

cp< PHPsrcdir> /sapi/fpm/init.d.PHP-fpm /etc/init.d/PHP-fpm

然后chmod它使其可执行

chmod 755 /etc/init.d/PHP-fpm

从这里,你可以做PHP-fpm< start | stop | force-quit | restart | reload>服务.

如果您删除PHP的源目录,也可以在下面找到该脚本.

#! /bin/sh

### BEGIN INIT INFO
# Provides:          PHP-fpm
# required-Start:    $remote_fs $network
# required-Stop:     $remote_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts PHP-fpm
# Description:       starts the PHP FastCGI Process Manager daemon
### END INIT INFO

prefix=/usr/local
exec_prefix=${prefix}

PHP_fpm_BIN=${exec_prefix}/sbin/PHP-fpm
PHP_fpm_CONF=${prefix}/etc/PHP-fpm.conf
PHP_fpm_PID=${prefix}/var/run/PHP-fpm.pid


PHP_opts="--fpm-config $PHP_fpm_CONF --pid $PHP_fpm_PID"


wait_for_pid () {
    try=0

    while test $try -lt 35 ; do

        case "$1" in
            'created')
            if [ -f "$2" ] ; then
                try=''
                break
            fi
            ;;

            'removed')
            if [ ! -f "$2" ] ; then
                try=''
                break
            fi
            ;;
        esac

        echo -n .
        try=`expr $try + 1`
        sleep 1

    done

}

case "$1" in
    start)
        echo -n "Starting PHP-fpm "

        $PHP_fpm_BIN --daemonize $PHP_opts

        if [ "$?" != 0 ] ; then
            echo " Failed"
            exit 1
        fi

        wait_for_pid created $PHP_fpm_PID

        if [ -n "$try" ] ; then
            echo " Failed"
            exit 1
        else
            echo " done"
        fi
    ;;

    stop)
        echo -n "Gracefully shutting down PHP-fpm "

        if [ ! -r $PHP_fpm_PID ] ; then
            echo "warning,no pid file found - PHP-fpm is not running ?"
            exit 1
        fi

        kill -QUIT `cat $PHP_fpm_PID`

        wait_for_pid removed $PHP_fpm_PID

        if [ -n "$try" ] ; then
            echo " Failed. Use force-quit"
            exit 1
        else
            echo " done"
        fi
    ;;

    force-quit)
        echo -n "Terminating PHP-fpm "

        if [ ! -r $PHP_fpm_PID ] ; then
            echo "warning,no pid file found - PHP-fpm is not running ?"
            exit 1
        fi

        kill -TERM `cat $PHP_fpm_PID`

        wait_for_pid removed $PHP_fpm_PID

        if [ -n "$try" ] ; then
            echo " Failed"
            exit 1
        else
            echo " done"
        fi
    ;;

    restart)
        $0 stop
        $0 start
    ;;

    reload)

        echo -n "Reload service PHP-fpm "

        if [ ! -r $PHP_fpm_PID ] ; then
            echo "warning,no pid file found - PHP-fpm is not running ?"
            exit 1
        fi

        kill -USR2 `cat $PHP_fpm_PID`

        echo " done"
    ;;

    *)
        echo "Usage: $0 {start|stop|force-quit|restart|reload}"
        exit 1
    ;;

esac
原文链接:https://www.f2er.com/php/139290.html

猜你在找的PHP相关文章