首页 > 系统相关 >nginx启动服务脚本

nginx启动服务脚本

时间:2023-04-28 15:05:24浏览次数:31  
标签:脚本 启动 stop pid echo nginx prog RETVAL


#chkconfig: 345 60 60
#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# it is v.0.0.2 version.
# chkconfig: - 85 15
# description: Nginx is a high-performance web and proxy server.
#              It has a lot of features, but it's not for everyone.
# processname: nginx
# pidfile: /var/run/nginx.pid
# config: /usr/nginx/conf/nginx.conf
nginxd=/usr/nginx/sbin/nginx
nginx_config=/usr/nginx/conf/nginx.conf
nginx_pid=/usr/nginx/logs/nginx.pid
RETVAL=0
prog="nginx"
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
[ -x $nginxd ] || exit 0
# Start nginx daemons functions.
start() {
if [ -e $nginx_pid ];then
   echo "nginx already running...."
   exit 1
fi
   echo -n $"Starting $prog: "
   daemon $nginxd -c ${nginx_config}
   RETVAL=$?
   echo
   [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
   return $RETVAL
}
# Stop nginx daemons functions.
stop() {
        echo -n $"Stopping $prog: "
        killproc $nginxd
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /usr/nginx/logs/nginx.pid
}
# reload nginx service functions.
reload() {
    echo -n $"Reloading $prog: "
    #kill -HUP `cat ${nginx_pid}`
    killproc $nginxd -HUP
    RETVAL=$?
    echo
}
# See how we were called.
case "$1" in
start)
        start
        ;;
stop)
        stop
        ;;
reload)
        reload
        ;;
restart)
        stop
        start
        ;;
status)
        status $prog
        RETVAL=$?
        ;;
*)
        echo $"Usage: $prog {start|stop|restart|reload|status|help}"
        exit 1
esac
exit $RETVAL



 

标签:脚本,启动,stop,pid,echo,nginx,prog,RETVAL
From: https://blog.51cto.com/u_16092550/6234181

相关文章

  • Linux中将memcached注册成服务并可以随机器启动时启动服务
    网上看了很多资料大多比较繁琐,而且很多不能再最新的centos6上执行成功,最后还是自己写了一份,以供日后备用:  1.首先是写service脚本service脚本需要进入到目录/etc/init.d中,然后touchmemcached,最后vimmemcached后进行脚本编写,脚本如下:#chkconfig:3456060#!/bin/bash......
  • shell脚本中if的“-e,-d,-f”
    文件表达式-efilename如果filename存在,则为真-dfilename如果filename为目录,则为真 -ffilename如果filename为常规文件,则为真-Lfilename如果filename为符号链接,则为真-rfilename如果filename可读,则为真 -wfilename如果filename可写,则为真 -xfilename如果fi......
  • Linux 实用shell脚本
    1.查看有多少远程的IP在连接本机#!/bin/bash#!/bin/bash#查看有多少远程的IP在连接本机(不管是通过ssh还是web还是ftp都统计)#使用netstat‐atn可以查看本机所有连接的状态,‐a查看所有,#-t仅显示tcp连接的信息,‐n数字格式显示#LocalAddress(第四......
  • wampserver 设置在windows下开机自动启动
    wampserver安装后默认是手动启动。想随开机自启动,需要在服务中设置一下。右键点开始进计算机管理点服务 将wampapache64 和wampmysqld64改为自动即可 ......
  • win安装mongo无法启动
    mongod安装后服务无法启动,要手动在指定目录下创建db文件夹,MongoDB.log文件不可提前创建,要在执行下面这条指令的时候才能生成,不然系统显示无权限mongod--dbpath=D:\app\mongo\data\db--logpath=D:\app\mongo\log\MongoDB.log--install--serviceName"MongoDB" ......
  • 通过yum方式安装Nginx
    Nginx的安装方式有两种分别是:通过Nginx源码(1)通过Nginx源码简单安装 (2)通过Nginx源码复杂安装 使用源码进行简单安装,我们会发现安装的过程比较繁琐,需要提前准备GCC编译器、PCRE兼容正则表达式库、zlib压缩库、OpenSSL安全通信的软件库包,然后才能进行Nginx的安装。这里不做......
  • jar包启动基础命令 java -jar common.jar cmd 命令行执行jar包
    jar包启动基础命令命令行执行jar包java-jarcommon.jar原文链接:https://blog.csdn.net/weixin_40483369/article/details/124392170一般情况下运行jar包,当前是可运行的jar包,直接命令java-jarcommon.jar1按下ctrl+C,关闭当前ssh或者直接关闭窗口,当前程序都会退出。......
  • 在Windows7下启动MongoDB服务的解决方案
      1:首先去官网下载程序,我用的是1.4.3版本,地址:http://downloads.mongodb.org/win32/mongodb-win32-i386-1.4.3.zip2:创建一个DB文件夹,我是放到D盘,路径:D:\Web\mongo\db3:打开CMD设置数据库的路径:D:\Web\mongo\bin\mongod.exe--dbpath=d:\Web\mongo\db4:重新打开CMD输......
  • Hadoop启动集群报错:Starting namenodes on [hadoop01] hadoop01: root@hadoop01: Per
    搭建三个hadoop集群的时候,master没有启动namenode和datanode,报错:Startingnamenodeson[hadoop01]hadoop01:root@hadoop01:Permissiondenied(publickey,gssapi-keyex,gssapi-with-mic,password).Startingdatanodeshadoop01:root@hadoop01:Permissiondenied(publicke......
  • phpstudy配置nginx跨域请问
    add_headerAccess-Control-Allow-Origin*; add_headerAccess-Control-Allow-Methods'GET,POST,OPTIONS'; add_headerAccess-Control-Allow-Headers'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Cont......