当前位置: 首页 > article >正文

Shell篇之编写php启动脚本

Shell篇之编写php启动脚本

1. 脚本内容

vim php-fpm_ctl.sh
#!/bin/bash

function_start(){
	/opt/nginx/php/php-fpm start
}

function_stop(){
	/opt/nginx/php/php-fpm stop
}

function_restart(){
	/opt/nginx/php/php-fpm restart
}

function_status(){
cgi_stat=0
cgi_tmpa=`ps -ef | grep cgi | grep root | grep -v grep | awk '{print $2}'`
cgi_tmpb=`cat /opt/nginx/php/logs/php-fpm.pid`
if [ `lsof -i:9000 | wc -l` -gt 0 ]; then
  if [ `ps -ef | grep php-cgi | grep -v grep | wc -l` -gt 0 ]; then
    if [ $cgi_tmpa -eq $cgi_tmpb ]; then
       cgi_stat=1
    fi
  fi
fi

if [ $cgi_stat -eq 1 ]; then
  echo "fastcgi(pid $cgi_tmpa) is runing!"
elif [ $cgi_stat -eq 0 ]; then
   echo "cgi is not runing!"
fi
}

if [ "$1" = "start" ]; then
	function_start
elif [ "$1" = "stop" ]; then
	function_stop
elif [ "$1" = "restart" ]; then
	function_restart
elif [ "$1" = "status" ]; then
	function_status
else
	printf "Usage: automate {start|stop|restart|status} \n"
fi

2. 赋权

chmod +x php-fpm_ctl.sh

3. 命令

./php-fpm_ctl.sh start
./php-fpm_ctl.sh status
./php-fpm_ctl.sh restart

http://www.kler.cn/news/314709.html

相关文章:

  • [python]从零开始的PySide安装配置教程
  • JavaEE: 深入探索TCP网络编程的奇妙世界(三)
  • Python实现图形学曲线和曲面的Bezier曲线算法
  • 深度学习-生成式检索-论文速读-2024-09-14
  • 关于自动化测试的一点了解
  • 高效财税自动化软件的特点与优势
  • ChatGPT 为何将前端框架从 Next.js 更换为 Remix以及框架的选择
  • Java中List、ArrayList与顺序表
  • hackmyvm靶场--zon
  • Spring:项目中的统一异常处理和自定义异常
  • 通过Java设计模式提高业务流程灵活性的策略
  • 笔记:DrawingContext和GDI+对比简介
  • 【Python】探索 TensorFlow:构建强大的机器学习模型
  • PostgreSQL技术内幕11:PostgreSQL事务原理解析-MVCC
  • 区块链DAPP质押系统开发
  • python中迭代器和可迭代对象
  • 【系统架构设计师】特定领域软件架构(经典习题)
  • 边缘智能-大模型架构初探
  • WebGL基础知识快速入门
  • 安装nuxt3
  • 「iOS」viewController的生命周期
  • Android TV RecyclerView列表获得焦点左右换行
  • 如何在Mac上安装多个Python环境
  • Spring Mybatis PageHelper分页插件 总结
  • MySQL篇(SQL优化)(持续更新迭代)
  • Android Studio 开发快速获取开发版和发布版SHA1和MD5
  • 汽车美容服务管理系统的数据库设计与数据操作
  • nvm 下载node报错:Could not retrieve https://nodejs.org/dist/index.json.
  • 奇安信渗透2面经验分享
  • HarmonyOS第一课-应用程序框架基础习题答案