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. 慕课网-Java入门第一季-7-2 Java 中无参无返回值方法的使用

    来源:http://www.imooc.com/code/1578 如果方法不包含参数,且没有返回值,我们称为无参无返回值的方法. 方法的使用分两步: 第一步,定义方法 例如:下面代码定义了一个方法名 ...

  2. AX7: Get started developing

    This blog will show how you can start making a customization in AX 7 by showing you the steps needed ...

  3. 优化servlet

    在最开始的时候我们写一个servlet(LoginServlet)对应一个请求(Login.jsp),这样的话就会产生很多的servlet,使其以后维护变得麻烦,所以我们可以考虑将同一类型(Login ...

  4. 常用linux维护命令

    cat /etc/issue  查看linux版本信息

  5. VS2013不显示最近打开文件

    首先点击开始在左下角输入"regedit" 右击HKEY_CURRENT_USER,点击查找,输入NoRecentDocsHistory 在右边找到NoRecentDocsHist ...

  6. 解决NetBeans编辑器中文乱码问题

    在JDK→JRE→lib目录下找到fontconfig.properties.src文件,打开,找到# Component Font Mappings,表示字体映射,可以看到下面列出了几种字体映射集合 ...

  7. jenkins:通过execute shell启动的进程会被杀死的问题

    [问题]在jenkins中配置自动更新部署项目时,如果采取用execute shell启动/关闭tomcat,会发现可以进行关闭tomcat,但是无法启动tomcat,虽然构建会显示执行成功,但是查看 ...

  8. 横向图片墙排列算法及demo

    演示地址: http://codeman35.itongyin.com:19005/v1/9gg_v2.html 功能: 按照不同的图片比例,进行横向9宫格排列,原则是尽量排列的整齐,不要多余出来格子 ...

  9. 关于Java static 的学习心得

    static,大家都很熟悉.但是要说真的懂,那就很少了.(当然我也不是很懂,但不妨碍学习吗.) 首先,我认为static修饰的成员就是属于类本身的成员.如果你加了一个static修饰符,好吧,那就相当 ...

  10. 转载-V.I.Arnold, beyond a mathematician

    转自-http://blog.renren.com/blog/248100754/471276636 在AMS的首页上找到了三条讣告,依次是V.I.Arnold(1937-2010),W.Rudin( ...