Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to start Shell script automatically when php-fpm starts up

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report