How to start Shell script automatically when php-fpm starts up
Editor to share with you how to achieve php-fpm boot automatically start Shell script, I believe that most people do not know much, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
There are various versions of php-fpm startup scripts online, but the source directory has already generated an automatic script after you compiled it. It can be used without any modification.
Cp {php-5.3.x-source-dir} / sapi/fpm/init.d.php-fpm / etc/init.d/php-fpm
The auto-startup script for php-fpm boot is as follows:
#! / bin/sh### BEGIN INIT INFO# Provides: php-fpm# Required-Start: $remote_fs $network# Required-Stop: $remote_fs $network# Default-Start: 2 34 "Default-Stop: 0 1" Short-Description: starts php-fpm# Description: starts the PHP FastCGI Process Manager daemon### END INIT INFO prefix=/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.pid php_opts= "- fpm-config $php_fpm_CONF-- pid $php_fpm_PID" wait_for_pid () {try=0 while test $try-lt 35 Do case "$1" in 'created') if [- f "$2"]; then try='' break fi;;' removed') if [!-f "$2"] Then try='' break fi; esac echo-n. Try= `expr $try + 1`expr 1 done} case "$1" 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 is 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;; force-quit) echo-n" Terminating php-fpm "if [!-r $php_fpm_PID]; then echo" warning, no pid file found-php-fpm is 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) $0 stop $0 start Reload) echo-n "Reload service php-fpm" if [!-r $php_fpm_PID]; then echo "warning, no pid file found-php-fpm is not running?" Exit 1 fi kill-USR2 `cat $php_fpm_ PID` echo "done"; *) echo "Usage: $0 {start | stop | force-quit | restart | reload}" exit 1;; esac is all the contents of the article "how to enable php-fpm to boot up the Shell script automatically". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!