centos 7下用了版本6下的脚本,总是报错,于是拷贝了nginx一键安装包里面的一个版本,结果可以,贴出来

#! /bin/sh
# chkconfig:
# Description: Startup script for nginx webserver on Debian. Place in /etc/init.d and
# run 'update-rc.d -f nginx defaults', or use the appropriate command on your
# distro. For CentOS/Redhat run: 'chkconfig --add nginx' ### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start:
# Default-Stop:
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
### END INIT INFO # Author: licess
# website: http://lnmp.org PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=nginx
NGINX_BIN=/usr/local/nginx/sbin/$NAME
CONFIGFILE=/usr/local/nginx/conf/$NAME.conf
PIDFILE=/usr/local/nginx/logs/$NAME.pid case "$1" in
start)
echo -n "Starting $NAME... " if netstat -tnpl | grep -q nginx;then
echo "$NAME (pid `pidof $NAME`) already running."
exit
fi $NGINX_BIN -c $CONFIGFILE if [ "$?" != ] ; then
echo " failed"
exit
else
echo " done"
fi
;; stop)
echo -n "Stoping $NAME... " if ! netstat -tnpl | grep -q nginx; then
echo "$NAME is not running."
exit
fi $NGINX_BIN -s stop if [ "$?" != ] ; then
echo " failed. Use force-quit"
exit
else
echo " done"
fi
;; status)
if netstat -tnpl | grep -q nginx; then
PID=`pidof nginx`
echo "$NAME (pid $PID) is running..."
else
echo "$NAME is stopped"
exit
fi
;; force-quit)
echo -n "Terminating $NAME... " if ! netstat -tnpl | grep -q nginx; then
echo "$NAME is not running."
exit
fi kill `pidof $NAME` if [ "$?" != ] ; then
echo " failed"
exit
else
echo " done"
fi
;; restart)
$ stop
sleep
$ start
;; reload)
echo -n "Reload service $NAME... " if netstat -tnpl | grep -q nginx; then
$NGINX_BIN -s reload
echo " done"
else
echo "$NAME is not running, can't reload."
exit
fi
;; configtest)
echo -n "Test $NAME configure files... " $NGINX_BIN -t
;; *)
echo "Usage: $0 {start|stop|force-quit|restart|reload|status|configtest}"
exit
;; esac

END!

centos 7 下nginx启动脚本的更多相关文章

  1. centos下nginx启动脚本和chkconfig管理

    在安装完nginx后,重新启动需要“kill -HUP nginx进程编号”来进行重新加载,显然十分不方便.如果能像apache一样,直接通过脚本进行管理就方便多了. nginx官方早就想好了,也提供 ...

  2. 在centos中创建nginx启动脚本

    1. 建立脚本文件nginxd [root@could]# vi /etc/init.d/nginxd 插入以下内容 #!/bin/bash## chkconfig: - 85 15# descrip ...

  3. centos LNMP第一部分环境搭建 LAMP LNMP安装先后顺序 php安装 安装nginx 编写nginx启动脚本 懒汉模式 mv /usr/php/{p.conf.default,p.conf} php运行方式SAPI介绍 第二十三节课

    centos  LNMP第一部分环境搭建 LAMP安装先后顺序  LNMP安装先后顺序 php安装 安装nginx  编写nginx启动脚本   懒汉模式  mv   /usr/local/php/{ ...

  4. Ubuntu下Nginx启动、停止等常用命令

    本文详细介绍Ubuntu下Nginx启动.停止等常用命令.在开发过程中,我们会经常的修改Nginx的配置文件,每次修改配置文件都可以先测试下本次修改的配置文件是否正确,可以利用以下命令: servic ...

  5. nginx启动脚本和配置文件

    1.编写Nginx启动脚本,并加入系统服务 vim /etc/init.d/nginx并在其中写入如下内容:#!/bin/bash# chkconfig: - 30 21# description: ...

  6. linux nginx 启动脚本

    linux nginx 启动脚本 [root@webtest76 ~]# vi /etc/init.d/nginx #!/bin/bash # nginx Startup script for the ...

  7. Nginx 启动脚本/重启脚本

    第一步先运行命令关闭nginx sudo kill `cat /usr/local/nginx/logs/nginx.pid` 第二步 vi /etc/init.d/nginx 输入以下内容 #!/b ...

  8. nginx启动脚本,手动编辑

    nginx启动脚本,手动编辑 #! /bin/bash # chkconfig: - # description: nginx service XDIR=/www/server/nginx DESC= ...

  9. Nginx 启动脚本

    Nginx 启动脚本 1.vim /etc/init.d/nginx #!/bin/bash # chkconfig: - 30 21 # description: http service. # S ...

随机推荐

  1. Swift版的SQLiteHelper

    SQLiteHelper 创建SQLiteHelper类 /// SQLite数据库处理帮助类 /// /// 此类中封装了关于SQLite数据库处理的业务函数 class SQLiteHelper ...

  2. [转载]http协议 文件下载原理及多线程断点续传

    最近研究了一下关于文件下载的相关内容,觉得还是写些东西记下来比较好.起初只是想研究研究,但后来发现写个可重用性比较高的模块还是很有必要的,我想这也是大多数开发人员的习惯吧.对于HTTP协议,向服务器请 ...

  3. 45个android实例源码

    分享45个android实例源码,很好很强大http://www.apkbus.com/android-20978-1-1.html andriod闹钟源代码http://www.apkbus.com ...

  4. android activity的启动方式

    1.Standard正常启动,默认的启动方式,没什么说头 2.SingleTop 意思就是在栈顶只能存在一个相同的activity 不能叠加,如果再A上继续启动A的话,只会调用A的onNewInten ...

  5. android-----test------模拟来电提醒和短信提醒

    为了测试应用是否能处理来电提醒和短信提醒时正常处理,我们需要做个测试,怎么模拟来电提醒和短信提醒呢?? 采用Telnet 命令来模拟. 1.首先看看Telnet 命令是否可以使用,如果不可以使用,则需 ...

  6. [转]:C#的ToString如何格式化字符串

    C 货币 2.5.ToString("C") ¥2.50 D 十进制数 25.ToString("D5") 00025 E 科学型 25000.ToString ...

  7. AngularJS-chapter2-7-前端路由

    Form表单提交会导致页面之间的切换,没法实现单页应用 Ajax请求不会留下History记录(在后台管理系统,没有后台历史记录还可以) ,但在网络型应用或门户型应用(用户没有办法给改页面加标签或分享 ...

  8. dede无子栏目的栏目直接调用顶级栏目(不让调用的解决方法) noself=\'yes\'

    大家在用dede做网站的时候经常会出现一个问题就是当调用子栏目的时候会出现无子栏目的栏目直接调用顶级栏目,   解决dede无子栏目时出现同级栏目的问题   {dede:channel type='s ...

  9. 设置MYECLIPSE的自动补全

    http://jingyan.baidu.com/article/d169e1869caf1e436611d8db.html

  10. 解决低版本chrome浏览器不支持es6 Array.find()

     if (!Array.prototype.find) {  Array.prototype.find = function(predicate) {    'use strict';    if ( ...