php-fpm init script

准备工作:

配置文件放在/etc/php-fpm.conf
端口设为9000。
将php-fpm进程文件设为/var/run/php-fpm.pid。

sudo mkdir /etc/init.d
sudo vim /etc/init.d/php-fpm

#!/bin/sh
#
# Simple php-fpm init script conceived to work on Unix
# as it dose use of the /proc fileSystem

EDISPORT=9000
EXEC=/usr/sbin/php-fpm
#STOP=kill cat /var/run/php-fpm.pid

PIDFILE=/var/run/php-fpm.pid
CONF="/etc/php-fpm.conf"

case "$1" in
    start)
        if [ -f $PIDFILE ]
        then
                echo "$PIDFILE exists, process is already running or crashed"
        else
                echo "Starting php-fpm server..."
                $EXEC
        fi
        ;;
    stop)
        if [ ! -f $PIDFILE ]
        then
                echo "$PIDFILE does not exist, process is not running"
        else
                PID=$(cat $PIDFILE)
                echo "Stopping ..."
                kill $PID
                while [ -x /proc/${PID} ]
                do
                    echo "Waiting for Redis to shutdown ..."
                    sleep 1
                done
                echo "php-fpm stopped"
        fi
        ;;
    *)
        echo "Please use start or stop as first argument"
        ;;
esac
JackSun

JackSun

I'm a coder.

You may also like...

Leave a Reply

Your email address will not be published.