• 编写nginx脚本,加入系统


    创建脚本文件

      [root@iZgt88z6l1kvd7Z conf]# vim /etc/init.d/nginx
    

    写入脚本

      #!/bin/bash
      # chkconfig: - 30 21
      # description: http service.
      # Source Function Library
      . /etc/init.d/functions
      # Nginx Settings
    
      NGINX_SBIN="/home/web/server/nginx/sbin/nginx"
      NGINX_CONF="/home/web/server/nginx/conf/nginx.conf"
      NGINX_PID="/home/web/server/nginx/logs/nginx.pid"
      RETVAL=0
      prog="Nginx"
    
      start() {
              echo -n $"Starting $prog: "
              mkdir -p /dev/shm/nginx_temp
              daemon $NGINX_SBIN -c $NGINX_CONF
              RETVAL=$?
              echo
              return $RETVAL
      }
    
      stop() {
              echo -n $"Stopping $prog: "
              killproc -p $NGINX_PID $NGINX_SBIN -TERM
              rm -rf /dev/shm/nginx_temp
              RETVAL=$?
              echo
              return $RETVAL
      }
    
      reload(){
              echo -n $"Reloading $prog: "
              killproc -p $NGINX_PID $NGINX_SBIN -HUP
              RETVAL=$?
              echo
              return $RETVAL
      }
      restart(){
              stop
              start
      }
      configtest(){
          $NGINX_SBIN -c $NGINX_CONF -t
          return 0
      }
    
      case "$1" in
        start)
              start
              ;;
        stop)
              stop
              ;;
        reload)
        reload
              ;;
        restart)
        restart
              ;;
        configtest)
        configtest
              ;;
        *)
              echo $"Usage: $0 {start|stop|reload|restart|configtest}"
              RETVAL=1
      esac
    
      exit $RETVAL
    

    更改执行权限

      [root@iZgt88z6l1kvd7Z conf]# chmod 755 /etc/init.d/nginx &&chkconfig --add nginx
  • 相关阅读:
    MVC3+Spring.net+NHibernate+ExtJs的简单架构
    WCF初见之Salt+Hash加密
    演讲时经常用到的几个小工具介绍
    2asp.net mvc 4 in action
    Hadoop简介和实践分享
    PyMongo非关系型数据库mongodb入门
    网络资源定位(Url)的奥秘
    ApplicationPoolIdentity
    CustomBehavior 入门
    架构培训
  • 原文地址:https://www.cnblogs.com/hxlinux/p/12912879.html
Copyright © 2020-2023  润新知