解决“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
# 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
 
大功告成!
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

老帽爬新坡

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值