歡迎您光臨本站 註冊首頁

把nginx和spawn-fcgi設為隨系統自動啟動 .

←手機掃碼閱讀     火星人 @ 2014-03-03 , reply:0

把nginx和spawn-fcgi設為隨系統自動啟動 .

把nginx和spawn-fcgi設為隨系統自動啟動 .


把 nginx 和 spawn-fcgi 設為隨系統自動啟動。view plaincopy to clipboardprint?
01.#!/bin/bash  
02.#  
03.# chkconfig: - 64 36  
04.# description:  This script take care of starting and stopping the nginx + spawn-fcgi server  
05.# processname: nginx + spawn-fcgi  
06.  
07.# file name: nginx  
08.# author: yagas  
09.# msn: yagas60@msn.com  
10.# date: 2011/11/25  
11.  
12.# Source function library.  
13.. /etc/rc.d/init.d/functions  
14.  
15.# Source networking configuration.  
16.. /etc/sysconfig/network  
17.  
18.  
19.pidfile="/var/run/nginx.pid"  
20.spawnfile="/usr/local/bin/spawn-fcgi"  
21.nginxfile="/usr/local/bin/nginx"  
22.  
23.start(){  
24.    if [ -e $spawnfile ]; then  
25.        $spawnfile -a 127.0.0.1 -p 9000 -C 10 -f /usr/bin/php-cgi > /dev/null 2>&1  
26.    res=$?  
27.    if [ $res == 0 ]; then  
28.        action "Starting spawn-fcgi: " /bin/true  
29.    else  
30.        action "Starting spawn-fcgi: " /bin/false  
31.    fi  
32.    else  
33.        action "Starting spawn-fcgi: " /bin/false  
34.    fi  
35.  
36.    if [ -e $nginxfile ]; then  
37.        $nginxfile > /dev/null 2>&1  
38.        res=$?  
39.    if [ $res == 0 ]; then  
40.        action "Starting nginx: " /bin/true  
41.    else  
42.        action "Starting nginx: " /bin/false  
43.    fi  
44.    else  
45.        action "Starting nginx: " /bin/false  
46.    fi  
47.      
48.    return $res  
49.}  
50.  
51.  
52.stop(){  
53.    ps -ef|grep php-cgi|awk '{cmd="kill -9 "$2; system(cmd);}'  
54.    spawn-fcgi=(ps -ef|grep php-cgi|wc -l)  
55.  
56.    if [ spawn-fcgi == 1 ]; then  
57.    action "Stoping spawn-fcgi: " /bin/true  
58.    else  
59.        action "Stoping spawn-fcgi: " /bin/false  
60.    fi  
61.      
62.    if [ -e $pidfile ]; then  
63.        kill -9 `cat ${pidfile}` > /dev/null 2>&1  
64.    res=$?  
65.        if [ $res == 0 ]; then  
66.        action "Stoping nginx: " /bin/true  
67.    else  
68.        action "Stoping nginx: " /bin/false  
69.    fi  
70.    else  
71.        killall nginx > /dev/null 2>&1  
72.    res=$?  
73.    fi  
74.  
75.    return $res  
76.}  
77.  
78.  
79.case "$1" in  
80.  start)  
81.    start  
82.    ;;  
83.  stop)  
84.    stop  
85.    ;;  
86.  restart)  
87.    stop  
88.    start  
89.    ;;  
90.  *)  
91.    echo {1}quot;Usage: $0 {start|stop|restart}"  
92.    exit 1  
93.esac  
94.  
95.exit $?  
《解決方案》

我才發了兩個小時不到,都轉載到這裡來了?真快呀。:em03:

[火星人 ] 把nginx和spawn-fcgi設為隨系統自動啟動 .已經有838次圍觀

http://coctec.com/docs/service/show-post-1647.html