Nginx没有启动文件、nginx服务不支持chkconfig、nginx无法自启
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无法自启的更多相关文章
- tomcat 服务不支持 chkconfig 以及其他服务不能添加到开机启动时的操作
在安装完tomcat后想添加的开机自启动的操作,但是报错tomcat 服务不支持 chkconfig,后来在 /etc/init.d/tomcat中的#!/bin/bash后添加上#chkconfi ...
- 服务不支持 chkconfig 的解决方法
系统服务,在chkconfig --add servername的时候老是提示服务不支持 chkconfig,经过查找,解决办法如下. 示例,auto_run的前三行如下:#!/bin/sh#chk ...
- 服务不支持 chkconfig 的解决办法
在chkconfig --add servername的时候老是提示服务不支持 chkconfig 经过查找,解决办法如下. 1.脚本tomcatstart前三行如下: #!/bin/bash #ch ...
- linux服务不支持chkconfig的解决
服务不支持chkconfig的解决 写了脚本,想用命令chkconfig加载自启动.提示xxxxxxx服务不支持chkconfig",原来是自己写的脚本时,忘记写两行了.开头一般要这样写 # ...
- 服务不支持 chkconfig 的解决方法
“服务不支持 chkconfig”: 请注意检查脚本的前面,是否有完整的两行:#chkconfig: 2345 80 90 #description:auto_run 在脚本前面这两行是不能少的 ...
- CetOS 服务不支持 chkconfig 的解决方法
今天在添加Elasticsearch系统自动启动服务的时候,提示 “服务 elasticsearch 不支持 chkconfig ”,如下图: 后来查找了下原因,是脚本编写的不符合规范,缺少关键的前三 ...
- 服务不支持chkconfig的解决
场景: 写了脚本,想用命令chkconfig加载自启动. chkconfig mongod on 解决方法: mongod 脚本的开头要这样加: #!/bin/bash #chkconfig:345 ...
- windows+nginx+iis+redis+Task.MainForm构建分布式架构 之 (nginx+iis构建服务集群)
本次要分享的是利用windows+nginx+iis+redis+Task.MainForm组建分布式架构,由标题就能看出此内容不是一篇分享文章能说完的,所以我打算分几篇分享文章来讲解,一步一步实现分 ...
- 初始nginx(启动运行) 使用nginx做一个简单的静态资源服务器
第一次接触nginx的时候,那时候公司还是用的一些不知名的小技术,后来公司发展问题,重新招了人,然后接触到nginx,公司 使用nginx用来做代理服务器,所有请求 都先经过nginx服务器,然后交由 ...
随机推荐
- 了解swagger
https://blog.csdn.net/i6448038/article/details/77622977 随着互联网技术的发展,现在的网站架构基本都由原来的后端渲染,变成了:前端渲染.先后端分离 ...
- pandas交叉表和透视表及案例分析
一.交叉表: 作用: 交叉表是一种用于计算分组频率的特殊透视图,对数据进行汇总 考察预测数据和正式数据的对比情况,一个作为行,一个作为列 案例: 医院预测病人病情: 真实病情如下数组(B:有病,M:没 ...
- Bootstrap 模态框 禁止点击空白关闭模态框事件
在模态框的div中加上 aria-hidden="true" data-backdrop="static" <div class="modal ...
- 01 Web框架介绍
一.Web框架本质 所有的web应用程序本质上都是socket,用户的浏览器其实就是一个socket客户端. python中常用的web框架有: Django Flask web.py WSGI(we ...
- Java中将字符串与unicode的相互转换工具类
unicode编码规则 unicode码对每一个字符用4位16进制数表示.具体规则是:将一个字符(char)的高8位与低8位分别取出,转化为16进制数,如果转化的16进制数的长度不足2位,则在其后补0 ...
- paper:synthesizable finit state machine design techniques using the new systemverilog 3.0 enhancements之全0/1/z/x的SV写法
- python-函数的对象、函数嵌套、名称空间和作用域
目录 函数的对象 函数对象的四大功能 引用 当做参数传给一个函数 可以当做函数的返回值 可以当做容器类型的元素 函数的嵌套 函数的嵌套定义 函数的嵌套调用 名称空间与作用域 名称空间 内置名称空间 全 ...
- LeetCode(120) Triangle
题目 Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacen ...
- city Engine 建模
基本操作介绍 界面布局,文件组织 五个常见图层 常见规则,替换思想
- ACM-ICPC 2018 徐州赛区网络预赛 I. Characters with Hash
Mur loves hash algorithm, and he sometimes encrypt another one's name, and call him with that encryp ...