#!/bin/bash # # chkconfig: 345 85 15 # description: PHP is an HTML-embedded scripting language # processname: php-fpm # config: /usr/local/php/etc/php.ini # Source function library. . /etc/rc.d/init.d/functions PHP_PATH=/usr/local DESC="php-fpm5.2" NAME=php-fpm version=php5.2.17 # php-fpm路径 DAEMON=$PHP_PATH/php/$version/sbin/$NAME # 配置文件路径 CONFIGFILE=$PHP_PATH/php/$version/etc/php-fpm.conf # PID文件路径(在php-fpm.conf设置) PIDFILE=$PHP_PATH/php/$version/logs/$NAME.pid SCRIPTNAME=/etc/init.d/$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 -n "Starting $DESC: $NAME" rh_start echo "." ;; stop) echo -n "Stopping $DESC: $NAME" rh_stop echo "." ;; reload) echo -n "Reloading $DESC configuration..." rh_reload echo "reloaded." ;; restart) echo -n "Restarting $DESC: $NAME" rh_stop sleep 1 rh_start echo "." ;; *) echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" >&2