This time to bring you PHP-FPM service startup script steps in detail, PHP-FPM service startup script considerations are what, the following is the actual case, take a look.
Create a self-boot file first:/etc/init.d/php-fpm
The contents are as follows:
#! /bin/sh### BEGIN INIT info# provides:php-fpm# required-start: $remote _fs $network # required-stop: $remote _fs $NETW ork# default-start:2 3 4 AA default-stop:0 1 6# short-description:starts php-fpm# description:starts the PHP Fa stcgi Process Manager daemon### END INIT infoprefix=/usr/local/phpexec_prefix=${prefix}php_fpm_bin=${exec_prefix}/ Sbin/php-fpmphp_fpm_conf=${prefix}/etc/php-fpm.confphp_fpm_pid=${prefix}/var/run/php-fpm.pidphp_opts= "-- Fpm-config $php _fpm_conf--pid $php _fpm_pid "Wait_for_pid () {try=0 while Test $try-lt; Eated ') if [-F "$"]; Then try= "Break fi;; ' Removed ') if [!-F "$"]; Then try= "Break fi;; Esac Echo-n. try= ' expr $try + 1 ' sleep 1 done}case "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 are 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;; status) if [!-R $php _fpm_pid]; Then echo "PHP-FPM is stopped" Exit 0 fi pid= ' cat $php _fpm_pid ' if ps-p $PID | Grep-q $PID; Then echo "PHP-FPM (PID $PID) is running ..." Else echo "php-fpm dead but PID file exists" FI;; Force-quit) echo-n "terminating php-fpm" if [! -R $php _fpm_pid]; Then echo "Warning, no PID file found-php-fpm are 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) $ stop $ start; Reload) echo-n "Reload service php-fpm" if [! -R $php _fpm_pid]; Then echo "Warning, no PID file found-php-fpm are not running?" Exit 1 fi kill-usr2 ' cat $php _fpm_pid ' echo ' done ';; *) echo "Usage: $ Start|stop|force-quit|restart|reload|status}" exit 1;; Esac
Configuring the PHP-FPM Service
# Set permissions chmod 755/etc/init.d/php-fpm# php-fpm join service chkconfig--add php-fpm# php-fpm level 234 set to start Chkconfig php-fpm on# View php-f PM Service Current configuration chkconfig--list php-fpmphp-fpm 0:off 1:off 2:on 3:on 4:on 5:on 6:off
PHP-FPM How to use
# Start Service php-fpm start# shutdown Service php-fpm stop# Restart service php-fpm restart# reload service php-fpm reload# Check Profile Service Php-f PM Configtest
Script description
# Source function library. . /etc/rc.d/init.d/functions # Source Networking configuration. . /etc/sysconfig/network
The above line of code someone would question what they do, '. ' is the source similar to the program in the include and require, the functions inside the method is all poured into this side, this procedure can be used, for example, this side of the daemon, status. The network in the second line is actually just a few lines, as follows
networking=yeshostname=e10162
Assign them as variables to determine whether the network card is started, if your nginx does not walk the network card, in fact, this paragraph can be removed.
Believe that you have read the case of this article you have mastered the method, more exciting please pay attention to the PHP Chinese network other related articles!
Recommended reading:
PHP and Ethereum Client interaction using the detailed
How to let 360 search engine included PHP rewrite method