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. 十一、Manipulators

    1. Manipulators是可以用三维进行绘制的的节点,可以将用户行为值化,对其他节点的属性进行modify. 2. 属性值可以通过Channel Box 和Graph Editor进行修改.同其 ...

  2. MongoDB常用操作

    (备注: 对于 window, 不需要sudo) 验证成功与否: * 启动服务器: $sudo mongod --dbpath C:\data\db (需要 指明数据库存放的目录) * 打开shell ...

  3. js解决IE不支持数组的indexOf()方法

    if (!Array.indexOf) {                                    Array.indexOf = function (obj) {            ...

  4. 线程Thread

    一.线程: 程序:保存在物理介质(光盘,软盘,硬盘)当中的代码片段 进程:一旦程序运行起来,就变成了操作系统当中的一个进程 线程:程序当中一条独立执行的线索 二.线程的五大状态 新生    就绪 运行 ...

  5. 用SQL语句获得一个存储过程返回的表

    1. 定义一个表变量 declare @table table(ReportType nvarchar(30),ReportPath nvarchar(200),ParaCnt int,DataAre ...

  6. uva11292 Dragon of Loowater

    水题,排序遍历即可 #include<iostream> #include<cstdio> #include<algorithm> using namespace ...

  7. Linux下随机密码生成器

    参考资料: 1:http://justwinit.cn/post/5164/ 2:http://www.linuxidc.com/Linux/2012-11/73687.htm

  8. UITableView的创建及其一些常用方法

    UITableView,它的数据源继承于UITableViewDataSource,它的委托UITableViewDelegate. 一.UITableView的创建 1.代码方式: UITableV ...

  9. Linux常用性能调优工具索引

    root@ubuntu:~# dstat----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system--usr sys i ...

  10. HttpClientUtils

    import java.io.IOException;import java.io.UnsupportedEncodingException;import java.util.List; import ...