zoukankan      html  css  js  c++  java
  • nginx--service配置

    nginx从今天开始进行相关学习了,包括:1、注册centos的service服务;2、相关的tomcat负载;3、https配置;4、session共享配置

    1、注册centos的service服务

    [root@localhost /]# cd /etc/init.d/
    [root@localhost init.d]# vim nginx

    #!/bin/sh
    #chkconfig: 2345  85 15   
    # 2345 表示在2345模式下,开机自启动
    # Simple Redis init.d script conceived to work on Linux systems
    # as it does use of the /proc filesystem.
     
    nginxd=/usr/local/nginx/sbin/nginx
    nginx_config=/usr/local/nginx/conf/nginx.conf
    nginx_pid=/usr/local/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 /var/run/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

    给添加权限

    chmod a+x /etc/init.d/nginx

    将nginx加入到,开启自启动项

    chkconfig --add nginx
    chkconfig nginx on

    测试

    [root@localhost init.d]# service nginx start
    Starting nginx: [ OK ]
    [root@localhost init.d]# service nginx stop
    Stopping nginx: [ OK ]
    [root@localhost init.d]# service nginx start
    Starting nginx: [ OK ]
    [root@localhost init.d]# service nginx reload
    Reloading nginx: [ OK ]

    我这里的环境是centos6.4如果是7以上还需要配置一些其他,这里不写了,可以网上找一下

    下一篇配置一下tomcat

  • 相关阅读:
    GJM :用JIRA管理你的项目(三)基于LDAP用户管理 [转载]
    GJM :用JIRA管理你的项目(二)JIRA语言包支持及插件支持 [转载]
    GJM : 用JIRA管理你的项目(一)JIRA环境搭建 [转载]
    javascripct导图
    Sublime Text 中使用Git插件连接GitHub
    使用webstorm上传代码到github
    jQuery.ajax()的一些例子
    jQuery.ajax()
    prefix和unprefix
    MVC , MVP , MVVM【转 阮一峰的网络日志】
  • 原文地址:https://www.cnblogs.com/aishangyizhihu/p/10196141.html
Copyright © 2011-2022 走看看