我们编译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>服务.
#! /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