免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1487 | 回复: 0
打印 上一主题 下一主题

解决“service nginx does not support chkconfig”的问题? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-04-24 23:35 |只看该作者 |倒序浏览
    因为这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
# description: nginx is a World Wide Web server. It is used to serve

其他的都不所谓,只是个注意而已!!!

修改后的nginx启动脚本:

#!/bin/bash
# Startup script for the nginx Web Server
# chkconfig: - 85 15
# 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
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

大功告成!




本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/25264/showart_576682.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP