解决“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

# 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




本文转自 xxl714 51CTO博客,原文链接:http://blog.51cto.com/dreamgirl1314/1564870,如需转载请自行联系原作者

相关文章
|
4月前
|
应用服务中间件 Linux PHP
【Azure 应用服务】App Service For Linux 环境中,如何修改 Nginx 配置中 server_name的默认值 example.com
【Azure 应用服务】App Service For Linux 环境中,如何修改 Nginx 配置中 server_name的默认值 example.com
|
4月前
|
应用服务中间件 Linux nginx
【Azure 应用服务】App Service For Container 配置Nginx,设置/home/site/wwwroot/目录为启动目录,并配置反向代理
【Azure 应用服务】App Service For Container 配置Nginx,设置/home/site/wwwroot/目录为启动目录,并配置反向代理
|
Kubernetes 负载均衡 应用服务中间件
k8s部署nginx(Pod、Deployment、Service)
k8s部署nginx(Pod、Deployment、Service)
2914 0
k8s部署nginx(Pod、Deployment、Service)
|
应用服务中间件 PHP nginx
Nginx报 No input file specified. 的问题解决之路
Nginx报 No input file specified 。哭啊,搞半天居然是这个东东~~~。看来还是经验不足,留此博文,记录一下并希望可以帮助到同样出现这个问题的童鞋。
31504 0
|
应用服务中间件 nginx
运行sudo service nginx restart,报错* Restarting nginx nginx[fail],启动不了nginx,启动nginx报错
运行sudo service nginx restart,报错* Restarting nginx nginx[fail],启动不了nginx,启动nginx报错
335 0
|
应用服务中间件 nginx C语言
nginx 编译出现的问题ngx_murmurhash.o failed
nginx 编译出现的问题ngx_murmurhash.o failed
2791 0
|
应用服务中间件 Linux nginx
CentOS 7 配置nginx的service 脚本例子
在CentOS 7下配置nginx为系统服务
9693 0
|
算法 应用服务中间件 Linux
关于docker swarm有满满干货的一篇文章,讲了如何用service来作nginx负责proxy已级无缝升级策略
http://www.cnblogs.com/atuotuo/p/6260591.html ================================= $docker network create -d overlay test   然后在同一个网络上分别吧应用容器和http服务容器...
1528 0