# set the PHP-FPM as a service and enable the boot to start automatically
# Description: The author has tested only on CentOS7.0 and has not been tested for reliability and stability!
Vi/etc/rc.d/init.d/fpmchmod +x/etc/rc.d/init.d/fpmchkconfig--add fpmchkconfig fpm on
The contents of the/ETC/RC.D/INIT.D/FPM file are as follows:
#! /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 onpath=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bindesc= "php-fpm Daemon "name=php-fpminstalldir=/opt/phpdaemon= $INSTALLDIR/sbin/$NAMECONFIGFILE = $INSTALLDIR/lib/$ name.confpidfile= $INSTALLDIR/var/run/$NAME. pidscriptname=/etc/init.d/$NAMEset -e[ -x "$DAEMON" ] | | exit 0do_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 "$" 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 ;; Esacexit 0
Use the following command:
Service FPM StartService fpm stopservice fpm restartservice fpm Test
This article is from the "twists and turns ◇2015" blog, please be sure to keep this source http://huangfuff.blog.51cto.com/2632203/1612655
PHP-FPM's CentOS boot start script