分享

转到nginx,用上php

 corefashion 2015-05-25
  1. #! /bin/sh  
  2. ### BEGIN INIT INFO  
  3. # Provides:          php-fastcgi  
  4. # Required-Start:    $all  
  5. # Required-Stop:     $all  
  6. # Default-Start:     2 3 4 5  
  7. # Default-Stop:      0 1 6  
  8. # Short-Description: Start and stop php-cgi in external FASTCGI mode  
  9. # Description:       Start and stop php-cgi in external FASTCGI mode  
  10. ### END INIT INFO  
  11. # Author: Kurt Zankl <[EMAIL PROTECTED]>  
  12. # Do NOT "set -e"  
  13. PATH=/sbin:/usr/sbin:/bin:/usr/bin  
  14. DESC="php-cgi in external FASTCGI mode"  
  15. NAME=fcgi-php  
  16. DAEMON=/usr/bin/php-cgi  
  17. PIDFILE=/var/run/$NAME.pid  
  18. SCRIPTNAME=/etc/init.d/$NAME  
  19. PHP_CONFIG_FILE=/etc/php5/cgi/php.ini  
  20. # Exit if the package is not installed  
  21. [ -x "$DAEMON" ] || exit 0  
  22. # Read configuration variable file if it is present  
  23. [ -r /etc/default/$NAME ] && . /etc/default/$NAME  
  24. # Load the VERBOSE setting and other rcS variables  
  25. . /lib/init/vars.sh  
  26. # Define LSB log_* functions.  
  27. # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.  
  28. . /lib/lsb/init-functions  
  29. # If the daemon is not enabled, give the user a warning and then exit,  
  30. # unless we are stopping the daemon  
  31. if [ "$START" != "yes" -a "$1" != "stop" ]; then  
  32.         log_warning_msg "To enable $NAME, edit /etc/default/$NAME and set START=yes"  
  33.         exit 0  
  34. fi  
  35. # Process configuration  
  36. export PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS  
  37. DAEMON_ARGS="-q -b $FCGI_HOST:$FCGI_PORT -c $PHP_CONFIG_FILE"  
  38. do_start()  
  39. {  
  40.         # Return  
  41.         #   0 if daemon has been started  
  42.         #   1 if daemon was already running  
  43.         #   2 if daemon could not be started  
  44.         start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null /  
  45.                 || return 1  
  46.         start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON /  
  47.                 --background --make-pidfile --chuid $EXEC_AS_USER --startas $DAEMON -- /  
  48.                 $DAEMON_ARGS /  
  49.                 || return 2  
  50. }  
  51. do_stop()  
  52. {  
  53.         # Return  
  54.         #   0 if daemon has been stopped  
  55.         #   1 if daemon was already stopped  
  56.         #   2 if daemon could not be stopped  
  57.         #   other if a failure occurred  
  58.         start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE > /dev/null # --name $DAEMON  
  59.         RETVAL="$?"  
  60.         [ "$RETVAL" = 2 ] && return 2  
  61.         # Wait for children to finish too if this is a daemon that forks  
  62.         # and if the daemon is only ever run from this initscript.  
  63.         # If the above conditions are not satisfied then add some other code  
  64.         # that waits for the process to drop all resources that could be  
  65.         # needed by services started subsequently.  A last resort is to  
  66.         # sleep for some time.  
  67.         start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON  
  68.         [ "$?" = 2 ] && return 2  
  69.         # Many daemons don't delete their pidfiles when they exit.  
  70.         rm -f $PIDFILE  
  71.         return "$RETVAL"  
  72. }  
  73. case "$1" in  
  74.   start)  
  75.         [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"  
  76.         do_start  
  77.         case "$?" in  
  78.                 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;  
  79.                 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;  
  80.         esac  
  81.         ;;  
  82.   stop)  
  83.         [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"  
  84.         do_stop  
  85.         case "$?" in  
  86.                 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;  
  87.                 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;  
  88.         esac  
  89.         ;;  
  90.   restart|force-reload)  
  91.         log_daemon_msg "Restarting $DESC" "$NAME"  
  92.         do_stop  
  93.         case "$?" in  
  94.           0|1)  
  95.                 do_start  
  96.                 case "$?" in  
  97.                         0) log_end_msg 0 ;;  
  98.                         1) log_end_msg 1 ;; # Old process is still running  
  99.                         *) log_end_msg 1 ;; # Failed to start  
  100.                 esac  
  101.                 ;;  
  102.           *)  
  103.                 # Failed to stop  
  104.                 log_end_msg 1  
  105.                 ;;  
  106.         esac  
  107.         ;;  
  108.   *)  
  109.         echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2  
  110.         exit 3  
  111.         ;;  
  112. esac  

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章