参考网址:http://www.jb51.net/article/120545.htm

# vi /etc/init.d/nginx

#!/bin/sh
# Name:nginx4comex
# nginx - this script starts and stops the nginx daemon
#
# 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: /comexHome/nginx/nginx.pid
#
# Created By http://comexchan.cnblogs.com/ # chkconfig: - 85 15
# description: nginx is a World Wide Web server. It is used to serve # Source function library.
. /etc/rc.d/init.d/functions # Source networking configuration.
. /etc/sysconfig/network # Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0 NGINX_DAEMON_PATH="/usr/local/nginx/sbin/nginx"
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"
NGINX_LOCK_FILE="/var/lock/subsys/nginx4comex"
prog=$(basename $NGINX_DAEMON_PATH) start() {
[ -x $NGINX_DAEMON_PATH ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
echo -n $"Starting $prog: "
daemon $NGINX_DAEMON_PATH -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $NGINX_LOCK_FILE
return $retval
} stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $NGINX_LOCK_FILE
return $retval
} restart() {
configtest || return $?
stop
start
} reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $NGINX_DAEMON_PATH -HUP
RETVAL=$?
echo
} force_reload() {
restart
} configtest() {
$NGINX_DAEMON_PATH -t -c $NGINX_CONF_FILE
} rh_status() {
status $prog
} rh_status_q() {
rh_status >/dev/null 2>&1
} case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac

必须要有这两句,否则无法用chkconfig添加到服务

# chkconfig: - 85 15
# description: nginx is a World Wide Web server. It is used to serve

nginx:在centos中自启动的更多相关文章

  1. centos中如何寻找Nginx,Apache,PHP,mysql的配置路径

    很多小伙伴都可能会碰到安装好环境之后忘记了或者不知道怎么查看配置环境的文件路径了, 下面我就来介绍centos中nginx.apache.php.mysql配置文件路径查看方法吧. 1.判断apach ...

  2. 在centos中安装最新版nginx,同时更改官方文档路径错误

    nginx的可以使用各平台的默认包来安装,本文是介绍使用源码编译安装,包括具体的编译参数信息. 正式开始前,编译环境gcc g ++开发库之类的需要提前装好,这里默认你已经装好. ububtu平台编译 ...

  3. CentOS中安装配置Nginx

    一.安装Nginx '首先我们需要在nginx官网中下载nginx安装包,在这就下载最新版 nginx-1.13.7版本 下载完成以后我们进入下载页面进行查看 下载文件目录为 home/userNam ...

  4. 在Centos中使用goaccess查看Nginx日志

    在Nginx的配置文件中配置一下access日志: log_format access ‘$remote_addr – $remote_user [$time_local] “$request” ‘‘ ...

  5. nginx在centos & ubuntu上的安装

    安装Centos 添加当前账号加入sudoers,具备sudo功能 安装编辑器vim Yum install vim Su root Cd cp /etc/sudoers /etc/sudoers[d ...

  6. Docker 实战(二)——centos7镜像安装nginx,将安装nginx的centos容器生成新的镜像,并导出

    Docker centos7镜像安装nginx 1.安装docker 使用yum安装docker不再重复:见  Linux常用命令 2.pull centos 1)在docker仓库中搜索centos ...

  7. centOS 开机自启动自己的脚本

    centOS 开机自启动自己的脚本 1. 自己脚本 myservice 如下: #!/bin/bash # chkconfig: # description: myservice .... echo ...

  8. ASP.NET Core Docker jexus nginx部署-CentOS实践版

    本文用图文的方式记录了我自己搭建centos+asp.net core + docker + jexus + nginx的整个过程,希望对有同样需求的朋友有一定的参考作用. 本文主要内容如下: cen ...

  9. Linux CentOS中防火墙的关闭及开启端口

    注:CentOS7之前用来管理防火墙的工具是iptable,7之后使用的是Firewall 样例:在CentOS7上安装tomcat后,在linux本机上可以访问tomcat主页,http://ip: ...

随机推荐

  1. Fast R-CNN论文阅读笔记

    论文地址:Fast R-CNN R-CNN的缺陷 (1)训练是一个多级的流水线.R-CNN首先在候选目标上微调一个卷积神经网络,使用log loss.然后使用SVMs充当目标分类器,以取代softma ...

  2. C++学习记录(留坑)

    #include <iostream> #include <ctime> #include <fstream> ///文件打开有o.i权限 #include < ...

  3. Win2008r2 由ESXi 转换到 HyperV的处理过程

    1. 大部分2008r2 采取了 windows loader的方式激活 这种方式 会导致hyperV 启动失败 因为他家在了错误的bios类型 所以第一步建议 使用windows loader 卸载 ...

  4. Pandas笔记目录

    速查笔记 使用实例 Pandas-数据导入 (未完成) Pandas-数据探索 基础属性 shape indexs columns values dtype/dtypes 汇总和计算描述统计 coun ...

  5. 伪数组(arguments及字符串)转数组的方法 贼简单

    超简单的伪数组转数组的方法, 简单到令人发指! (这里伪数组使用arguments) 1.使用 Array.prototype.slice Array.prototype.slice.call(arg ...

  6. 初征——NOIP2018游记

    前言 从最初接触oi到今年noip到来,也已经将近有一年了.从对于程序一窍不懂到现在开始学习算法,只是短短的不到一年的时间罢了.这次noip,不仅仅是我oi生涯的第一次noip,更是相当于是对我这一年 ...

  7. spring MVC 统一异常处理(webapi和web分开处理)

    转载: http://blog.csdn.net/m13321169565/article/details/7641978 http://blog.csdn.net/ethan_fu/article/ ...

  8. hdu 1540 Tunnel Warfare (线段树 区间合并)

    Tunnel Warfare Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)To ...

  9. java web 验证码-数字不变形

    controller代码: import java.awt.Color; import java.awt.Font; import java.awt.Graphics2D; import java.a ...

  10. ASP.NET MVC —— Model之一模型模板

    http://www.cnblogs.com/lzhp/archive/2013/03/25/2981650.html Mvc model系列文章主要分为三部分:Model Templates,Mod ...