>  기사  >  백엔드 개발  >  LNMP环境下php-fpm启动脚本

LNMP环境下php-fpm启动脚本

WBOY
WBOY원래의
2016-06-20 12:56:351188검색

安装LNMP环境,PHP5.4.37版本安装成功,添加php-fpm服务到系统启动项时,报错service php-fpm does not support chkconfig;php-fpm服务不支持chkconfig; 

编辑/etc/init.d/php-fpm启动脚本,打开之后是乱码,查找原因是拷贝php-fpm启动脚本文件错误。

从同样环境下同样的php版本拷贝php-fpm启动脚本,重新编辑黏贴过来,保存退出后,可以正常加入启动项;有遇到同样情况的朋友可以直接复制脚本,保持与脚本内容的路径一样即可。


php-fpm启动脚本参考如下:

#! /bin/sh### BEGIN INIT INFO# Provides:          php-fpm# Required-Start:    $remote_fs $network# Required-Stop:     $remote_fs $network# Default-Start:     2 3 4 5# Default-Stop:      0 1 6# Short-Description: starts php-fpm# Description:       starts the PHP FastCGI 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 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`  sleep 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 ;; 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 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|status}"  exit 1 ;;esac





성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.