天天看點

解決“service nginx does not support chkconfig”的問題?

解決“service nginx does not support chkconfig”的問題?

    因為這2天要安裝nginx伺服器,其nginx沒有提供啟動腳本,就想自己寫一個啟動腳本,但是再寫完腳本的時候,想使用service啟動該服務,

nginx啟動腳本如下:

#!/bin/bash

# Startup script for the nginx Web Server

# description: nginx is a World Wide Web server. It is used to serve

# HTML files and CGI.

# processname: nginx

# pidfile: /usr/local/nginx/logs/nginx.pid

# config: /usr/local/nginx/conf/nginx.conf

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin

export PATH

NGINX_HOME=/usr/local/nginx/sbin

NGINX_CONF=/usr/local/nginx/conf

PHP_HOME=/usr/local/php-fcgi/bin

if [ ! -f "$NGINX_HOME/nginx" ]

then

    echo "nginxserver startup: cannot start"

    exit

fi

case "$1" in

    'start')

        $PHP_HOME/spawn-fcgi -a 127.0.0.1 -p 10080 -C 20 -u nobody -f $PHP_HOME/php-cgi

        $NGINX_HOME/nginx -c $NGINX_CONF/nginx.conf

        echo "nginx start successful"

        ;;

    'stop')

        killall -TERM php-cgi

        killall -TERM nginx

esac

[root@node1 ~]# chkconfig --add nginx

service nginx does not support chkconfig

很是奇怪,後經過查找資料,發現如果想添加腳本用service啟動,必須要腳本裡面包含這2行:

# chkconfig: - 85 15

其他的都不所謂,隻是個注意而已!!!

修改後的nginx啟動腳本:

ok ,沒有錯誤提示,說明添加成功!啟動下看看,

[root@node1 ~]# service nginx stop

/sbin/service: line 68: 18616 Terminated              env -i LANG="$LANG" PATH="$PATH" TERM="$TERM" "${SERVICEDIR}/${SERVICE}" ${OPTIONS}

[root@node1 ~]# service nginx start

spawn-fcgi.c.190: child spawned successfully: PID: 18624

nginx start successful

本文轉自 xxl714 51CTO部落格,原文連結:http://blog.51cto.com/dreamgirl1314/1564870,如需轉載請自行聯系原作者

繼續閱讀