Nginx没有启动文件、nginx服务不支持chkconfig、nginx无法自启


问题描述:

Nginx安装后,当想要设置Ngixn为开机启动时,

就需要把nginx的启动命令路径放到/etc/rc.d/rc.local文件里面。

这个时候就会出现几个问题:

(1)目录中找不到nginx的启动命令文件。

(2)目录中找到了,但是使用chkconfig nginx on添加到启动项时,失败。


解决:

nginx启动文件,文件名为nginx,在nginx安装目录中,覆盖目录中的文件,

注意:内容中的路径如果需要修改请及时修改:

#!/bin/sh
#
#nginx - this script starts and stops the nginx daemin
#
# chkconfig: -
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /usr/local/nginx/conf/nginx.conf
# pidfile: /usr/local/nginx/logs/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit
nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
lockfile=/var/lock/subsys/nginx
start() {
[ -x $nginx ] || exit
[ -f $NGINX_CONF_FILE ] || exit
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq ] && rm -f $lockfile
return $retval
}
restart() {
configtest || return $?
stop
start
}
reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null >&
}
case "$1" in
start)
rh_status_q && exit
$
;;
stop)
rh_status_q || exit
$
;;
restart|configtest)
$
;;
reload)
rh_status_q || exit
$
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit
esac

然后进行配置:

cp nginx /etc/init.d/  #复制刚才的文件,到/etc/init.d下。

chmod 755 /etc/init.d/nginx  #设置权限
chkconfig nginx on  #设置开机启动

然后就可以使用命令:service nginx start | stop | restart | status 。


Nginx没有启动文件、nginx服务不支持chkconfig、nginx无法自启的更多相关文章

  1. tomcat 服务不支持 chkconfig 以及其他服务不能添加到开机启动时的操作

    在安装完tomcat后想添加的开机自启动的操作,但是报错tomcat 服务不支持 chkconfig,后来在  /etc/init.d/tomcat中的#!/bin/bash后添加上#chkconfi ...

  2. 服务不支持 chkconfig 的解决方法

    系统服务,在chkconfig --add  servername的时候老是提示服务不支持 chkconfig,经过查找,解决办法如下. 示例,auto_run的前三行如下:#!/bin/sh#chk ...

  3. 服务不支持 chkconfig 的解决办法

    在chkconfig --add servername的时候老是提示服务不支持 chkconfig 经过查找,解决办法如下. 1.脚本tomcatstart前三行如下: #!/bin/bash #ch ...

  4. linux服务不支持chkconfig的解决

    服务不支持chkconfig的解决 写了脚本,想用命令chkconfig加载自启动.提示xxxxxxx服务不支持chkconfig",原来是自己写的脚本时,忘记写两行了.开头一般要这样写 # ...

  5. 服务不支持 chkconfig 的解决方法

    “服务不支持 chkconfig”: 请注意检查脚本的前面,是否有完整的两行:#chkconfig: 2345 80 90    #description:auto_run 在脚本前面这两行是不能少的 ...

  6. CetOS 服务不支持 chkconfig 的解决方法

    今天在添加Elasticsearch系统自动启动服务的时候,提示 “服务 elasticsearch 不支持 chkconfig ”,如下图: 后来查找了下原因,是脚本编写的不符合规范,缺少关键的前三 ...

  7. 服务不支持chkconfig的解决

    场景: 写了脚本,想用命令chkconfig加载自启动. chkconfig mongod on 解决方法: mongod 脚本的开头要这样加: #!/bin/bash #chkconfig:345 ...

  8. windows+nginx+iis+redis+Task.MainForm构建分布式架构 之 (nginx+iis构建服务集群)

    本次要分享的是利用windows+nginx+iis+redis+Task.MainForm组建分布式架构,由标题就能看出此内容不是一篇分享文章能说完的,所以我打算分几篇分享文章来讲解,一步一步实现分 ...

  9. 初始nginx(启动运行) 使用nginx做一个简单的静态资源服务器

    第一次接触nginx的时候,那时候公司还是用的一些不知名的小技术,后来公司发展问题,重新招了人,然后接触到nginx,公司 使用nginx用来做代理服务器,所有请求 都先经过nginx服务器,然后交由 ...

随机推荐

  1. ubuntu系统普通用户密码忘记之重置

    当我们在使用ubuntu系统忘记普通用户登录密码的时候,会被系统在登录界面拒之门外而不得入,这时候只好需要我们去重新设置密码,具体做法如下: 系统重启,在GRUB模式下选择Advanced Optio ...

  2. (68)zabbix windows性能计数器使用详解

    概述 windows下的性能计数器让zabbix监控更加轻松,直接获取性能计数器的数值即可完成windows监控.性能计数器如下:   1 perf_counter["\Processor( ...

  3. 使用jmeter做简单的压测(检查点、负载设置、聚合报告)

    1.添加断言(检查点) 在需要压测的接口下添加--断言--响应断言,取接口响应中包含有的数据即可 检查点HTTP请求-->断言-->响应断言1.名称.注释2.Apply to//作用于哪里 ...

  4. Beyond Compare4.x 破解方案

    如果过了30天的评估期或报“Beyond Compare 许可证密钥被撤销” 而导致不能再打开Beyond Compare,可以用下面的方法来解决: 1.找到“C:\Users\[Your User ...

  5. python数据类型之列表(list)和其常用方法

    列表是python常用数据类型之一,是可变的,可由n = []创建,也可由n = list()创建,第一种方法更常用. 常用方法总结: # 创建方法 n = [] 或者 n = list() # in ...

  6. Linux异常体系之stubs_offset

    转自 http://www.xuebuyuan.com/2208550.html 在ARM V4及V4T以后的大部分处理器中,中断向量表的位置可以有两个位置:一个是0x00000000,另一个是0xf ...

  7. poj 1862 2*根号(n1*n2)问题 贪心算法

    题意: 有n个数,要把其中2个数进行2*根号(n1*n2)操作,求剩下最小的那个数是多少? 哭诉:看题目根本没看出来要让我做这个操作. 思路: 每次把最大的,次大的拿出来进行操作 用"优先队 ...

  8. Python属性描述符(二)

    Python存取属性的方式特别不对等,通过实例读取属性时,通常返回的是实例中定义的属性,但如果实例未曾定义过该属性,就会获取类属性,而为实例的属性赋值时,通常会在实例中创建属性,而不会影响到类本身.这 ...

  9. python 提交form-data之坑

    #coding=utf-8 import requests from requests_toolbelt import MultipartEncoder #requests库上传 files = {& ...

  10. luogu2564 [SCOI2009]生日礼物

    排序枚举左端点,则右端点必定不降 #include <algorithm> #include <iostream> #include <cstring> #incl ...