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服务器,然后交由 ...
随机推荐
- console.log与console.dir的区别
今天学习promise的时候看到了console.dir这个方法,感到很好奇,查了以下感觉又长知识了 在Chrome中,控制台对象定义了两个似乎做同样事情的方法: console.log() cons ...
- 洛谷 P5015 标题统计
第一道题很简单,标签:字符串.模拟. 只需要一个判断去除空格就对了: if(a[i]!=' ' && a[i]!='\n') v++; code: #include<iostre ...
- Mybatis 循环 foreach, 批量操作
mapper.java: int modifySortOfGoods(@Param("idlist") List<String> goodsIds, @Param(&q ...
- 【Maven】 (请使用 -source 8 或更高版本以启用 lambda 表达式)
在使用mvn install编译maven项目时,报了 “ (请使用 -source 8 或更高版本以启用 lambda 表达式)”错误,是因为设置的maven默认jdk编译版本太低的问题. 可使用两 ...
- OpenCV编译 Make出错 recipe for target 'modules/imgproc/CMakeFiles/opencv_test_imgproc.dir/all' failed
OpenCV编译 Make出错 recipe for target 'modules/imgproc/CMakeFiles/opencv_test_imgproc.dir/all' failed 添 ...
- shutil,zipfile,tarfile模块
一,shutil模块 1.shutil.chown() shutil.chown('test.txt',user='mysql',group='mysql') #改变文件的属主和属组. 2.shuti ...
- UVa 1354 枚举子集 Mobile Computing
只要枚举左右两个子天平砝码的集合,我们就能算出左右两个悬挂点到根悬挂点的距离. 但是题中要求找尽量宽的天平但是不能超过房间的宽度,想不到要怎样记录结果. 参考别人代码,用了一个结构体的vector,保 ...
- 《百词斩·象形9000》第一册(下) 符号Symbol 1
001-version n.版本:译文 This is the first version of the software #这是软件开发的第一个版本: 002-element n.成分:要素:元素: ...
- python week08 并发编程之多进程--实践部分
一 multiprocessing模块介绍 python中的多线程无法利用多核优势,如果想要充分地使用多核CPU的资源(os.cpu_count()查看),在python中大部分情况需要使用多进程.P ...
- python 学习分享-字典篇
python字典(Dictionary) dict是无序的 key必须是唯一切不可变的 a={'key1':'value1','key2':'value2'} 字典的增删改查 a['key3']='v ...