php-fpm的CentOS开机自启脚本
# 将php-fpm设置成服务,并实现开机自动启动
创新互联是一家专注于做网站、网站制作与策划设计,昆都仑网站建设哪家好?创新互联做网站,专注于网站建设十余年,网设计领域的专业建站公司;建站业务涵盖:昆都仑等地区。昆都仑做网站价格咨询:028-86922220
# 说明:作者仅在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
本文标题:php-fpm的CentOS开机自启脚本
网页网址:http://azwzsj.com/article/ggiiso.html