# 将php-fpm设置成服务,并实现开机自动启动
# 说明:作者仅在CentOS7.0上进行了测试,而且没有进行可靠性和稳定性的测试!
vi /etc/rc.d/init.d/fpm chmod +x /etc/rc.d/init.d/fpm chkconfig --add fpm chkconfig fpm on
/etc/rc.d/init.d/fpm文件的内容如下:
#! /bin/sh #chkconfig: 2345 60 90 ## vi /opt/php/etc/php-fpm.conf #uncomment pid under [global] #pid = run/php-fpm.pid ## vi /etc/rc.d/init.d/fpm ## chmod +x /etc/rc.d/init.d/fpm ## chkconfig --add fpm ## chkconfig fpm on PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DESC="php-fpm daemon" NAME=php-fpm INSTALLDIR=/opt/php DAEMON=$INSTALLDIR/sbin/$NAME CONFIGFILE=$INSTALLDIR/lib/$NAME.conf PIDFILE=$INSTALLDIR/var/run/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME set -e [ -x "$DAEMON" ] || exit 0 do_start() { $DAEMON -D || echo -n "php-fpm already running" } do_stop() { kill -INT `cat $PIDFILE` || echo -n "php-fpm not running" } do_test() { $DAEMON -t || echo -n "php-fpm can't test" } case "$1" in start) echo -n "Starting $DESC: $NAME" do_start echo "." ;; stop) echo -n "Stopping $DESC: $NAME" do_stop echo "." ;; restart) echo -n "Restarting $DESC: $NAME" do_stop do_start echo "." ;; test) echo -n "Testing $DESC: $NAME" do_test echo "." ;; *) echo "Usage: $SCRIPTNAME {start|stop|restart|test}" >&2 exit 3 ;; esac exit 0
使用命令如下:
service fpm start service fpm stop service fpm restart service fpm test
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。