php fastcgi 启动脚本

以FASTCGI模式启动PHP,通过此脚本,可以以守护进程模式启动PHP的FASTCGI模式。

启动脚本 /home/hliang/fcgi-php:

[cc lang=”php”]#! /bin/sh

### BEGIN INIT INFO

# Provides: php-fastcgi

# Required-Start: $all

# Required-Stop: $all

# Default-Start: 2 3 4 5

# Default-Stop: 0 1 6

# Short-Description: Start and stop php-cgi in external FASTCGI mode

# Description: Start and stop php-cgi in external FASTCGI mode

### END INIT INFO

# Author: Kurt Zankl

# Do NOT “set -e”

PATH=/sbin:/usr/sbin:/bin:/usr/bin

DESC=”php-cgi in external FASTCGI mode”

NAME=fcgi-php

DAEMON=/usr/local/php/bin/php-cgi

PIDFILE=/var/run/$NAME.pid

SCRIPTNAME=/home/hliang/app/shell/$NAME

PHP_CONFIG_FILE=/usr/local/php/lib/php.ini

# Exit if the package is not installed

[ -x “$DAEMON” ] || exit 0

# Read configuration variable file if it is present

[ -r /etc/default/$NAME ] && . /etc/default/$NAME

# Load the VERBOSE setting and other rcS variables

. /lib/init/vars.sh

# Define LSB log_* functions.

# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.

. /lib/lsb/init-functions

# If the daemon is not enabled, give the user a warning and then exit,

# unless we are stopping the daemon

if [ “$START” != “yes” -a “$1” != “stop” ]; then

log_warning_msg “To enable $NAME, edit /etc/default/$NAME and set START=yes”

exit 0

fi

# Process configuration

export PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS

DAEMON_ARGS=”-q -b $FCGI_HOST:$FCGI_PORT -c $PHP_CONFIG_FILE”

do_start()

{

# Return

# 0 if daemon has been started

# 1 if daemon was already running

# 2 if daemon could not be started

start-stop-daemon –start –quiet –pidfile $PIDFILE –exec $DAEMON –test > /dev/null || return 1

start-stop-daemon –start –quiet –pidfile $PIDFILE –exec $DAEMON –background –make-pidfile –chuid $EXEC_AS_USER –startas $DAEMON — $DAEMON_ARGS || return 2

}

do_stop()

{

# Return

# 0 if daemon has been stopped

# 1 if daemon was already stopped

# 2 if daemon could not be stopped

# other if a failure occurred

start-stop-daemon –stop –quiet –retry=TERM/30/KILL/5 –pidfile $PIDFILE > /dev/null # –name $DAEMON

RETVAL=”$?”

[ “$RETVAL” = 2 ] && return 2

# Wait for children to finish too if this is a daemon that forks

# and if the daemon is only ever run from this initscript.

# If the above conditions are not satisfied then add some other code

# that waits for the process to drop all resources that could be

# needed by services started subsequently. A last resort is to

# sleep for some time.

start-stop-daemon –stop –quiet –oknodo –retry=0/30/KILL/5 –exec $DAEMON

[ “$?” = 2 ] && return 2

# Many daemons don’t delete their pidfiles when they exit.

rm -f $PIDFILE

return “$RETVAL”

}

case “$1” in

start)

[ “$VERBOSE” != no ] && log_daemon_msg “Starting $DESC” “$NAME”

do_start

case “$?” in

0|1) [ “$VERBOSE” != no ] && log_end_msg 0 ;;

2) [ “$VERBOSE” != no ] && log_end_msg 1 ;;

esac

;;

stop)

[ “$VERBOSE” != no ] && log_daemon_msg “Stopping $DESC” “$NAME”

do_stop

case “$?” in

0|1) [ “$VERBOSE” != no ] && log_end_msg 0 ;;

2) [ “$VERBOSE” != no ] && log_end_msg 1 ;;

esac

;;

restart|force-reload)

log_daemon_msg “Restarting $DESC” “$NAME”

do_stop

case “$?” in

0|1)

do_start

case “$?” in

0) log_end_msg 0 ;;

1) log_end_msg 1 ;; # Old process is still running

*) log_end_msg 1 ;; # Failed to start

esac

;;

*)

# Failed to stop

log_end_msg 1

;;

esac

;;

*)

echo “Usage: $SCRIPTNAME {start|stop|restart|force-reload}” >&2

exit 3

;;

esac[/cc]

配置文件,保存在 /etc/default/fcgi-php

[cc lang=”php”]START=yes

# Which user runs PHP? (default: www-data)

EXEC_AS_USER=www-data

# Host and TCP port for FASTCGI-Listener (default: localhost:9000)

FCGI_HOST=127.0.0.1

FCGI_PORT=9000

# Environment variables, which are processed by PHP

PHP_FCGI_CHILDREN=4

PHP_FCGI_MAX_REQUESTS=1000[/cc]

启动服务:

[cc lang=”php”]/home/hliang/fcgi-php start[/cc]

关闭服务:

[cc lang=”php”]/home/hliang/fcgi-php stop[/cc]

重启服务:

[cc lang=”php”]/home/hliang/fcgi-php restart

/home/hliang/fcgi-php force-reload[/cc]

php fastcgi进程启动,php fastcgi 启动脚本相关推荐

  1. php fastcgi进程启动,如何设置nginx的php fastcgi进程数

    九州编程 源码包可以在官方主页上下载.Ubuntu 7.10可以直接通过apt安装,也可以从这里下载最新的deb包:sudo apt-get install nginx如果要自己编译的话,需要确保自己 ...

  2. php 脚本 fpm缓存,PHP生命周期及fpm(FastCGI进程管理器)的运作方式

    PHP在web方式中如何改了文件就立即生效的,重要的几个概念:sapi: 可以简单的理解为php引擎对外的一个统一接口,使得php可以和外部程序进行交互 php的生命周期中关键四个调用: MINT - ...

  3. learn.log - 进程管理器fastcgi原理及fastcgi_param详解

    一. 何为FastCGI?  in all : 快-不崩溃-优雅 fast-strong-high FastCGI官方站点:http://www.fastcgi.com.common gateway  ...

  4. FastCGI 进程管理器(FPM)

    FastCGI 进程管理器 FPM(FastCGI 进程管理器)是 PHP FastCGI 的主要实现,包含大部分对高负载网站有用的功能. 它的功能包括: 支持平滑停止/启动的高级进程管理功能: 进程 ...

  5. FastCGI 进程管理器(FPM)配置项目列表

    FPM 使用类似 php.ini 语法的 php-fpm.conf 和进程池配置文件. php-fpm.conf 全局配置段 pid string PID 文件的位置.默认为空. error_log  ...

  6. linux根据进程号PID查找启动程序的全路径

    问题提出 有的时候想重启一个服务,但是不知道启动命令在哪,这就很尴尬,如果能通过进程ID反推到启动的脚本位置,那就很舒服了,结果还真能 复现 我们以重启redis为例,首先要找到服务的进程号 ps - ...

  7. 一种创建进程间COM来启动IE的方式

    一种创建进程间COM来启动IE(也不一定是IE,现在很多IE内核的浏览器,也实现了这个服务接口)的方式. 另外,如果把空上进程间的方式改为进程内的方式,就是WebBrowser了 #include & ...

  8. Redis 错误1067:进程意外终止,Redis不能启动,Redis启动不了

    Redis 错误1067:进程意外终止,Redis不能启动,Redis启动不了 >>>>>>>>>>>>>>> ...

  9. PHP运行环境之IIS FastCGI 进程意外退出解决办法

    本机做了系统,结果之前装好的APACHE环境什么的都没了,不想费事了,这次直接使用WIN8自带的IIS功能了,安装完毕后提示FastCGI 进程意外退出解决办法,这是由于某些加载库加载失败的原因,这里 ...

  10. bat执行exe程序_dos命令start教程,并行运行exe程序或者启动bat批处理cmd脚本

    大家好,我是老盖,首先感谢观看本文,本篇文章做的有视频,视频讲述的比较详细,也可以看我发布的视频. 今天我们学习DOS命令start这个命令,它可以启动一个EXE程序,也可以启动一个BAT批处理脚本, ...

最新文章

  1. 新建SVN Repository
  2. SAP针对中国市场推出双轨制医疗计划
  3. PRML 十大经典机器学习算法
  4. YAML语法详细总结
  5. 排列组合思维导图_巧用思维导图做数学单元整理
  6. 【警告】扣扣热键你了解多少
  7. 任务栏右键工具栏里的语言栏没有的修复.reg
  8. iphone 计算文件长度
  9. Javascript中的原型链,__proto__和prototype等问题总结
  10. 使用UUID生成32位ID
  11. OTA升级功能系列三(MD5加密)
  12. 抓包工具fiddler使用与理论的理解
  13. python找出列表中最长/短的字符串及他们的长度、下标
  14. hihoCoder #1246 王胖浩与环
  15. IB 物理真题: 比潜热、理想气体
  16. 【MicroPython ESP32】1.8“tft ST7735驱动3Dcube图形显示示例
  17. 电子音乐及HOUSE的分类知识
  18. 数据库表设计字段说明
  19. MOS管选型需要注意四大点-方案商选型可查看-KIA MOS管
  20. TLS-DTLS-SRTP相关总结

热门文章

  1. 记录使用.netcore 完成微信公众号推送模板消息
  2. 《货币战争2-金权天下》杂录。。这本书读了之后我觉得有点对努力和奋斗失去信心,所以。
  3. QT中ui文件生成关联的C++类
  4. 还不了解后端资源拦截和权限认证?过滤器,拦截器,AOP,SpringSecurity教教你
  5. 2013年5月22日 Dave 在深圳
  6. OriginPro2021安装LaTeX插件教程
  7. 关于netkeep连不了网的一个问题(点击连接互联网后按钮变灰色)
  8. 用C语言模拟面向对象
  9. 如何下载脚本之家的百度云盘共享电子书
  10. opporeno5可以用鸿蒙系统,买了OPPO Reno5系列 一定要试试这些功能