zoukankan      html  css  js  c++  java
  • 装tomcat和nginx心得

    开机启动tomcat

    1:在/etc/rc.d/init.d目录下生成一个文件tomcat8080

    2:在文件里添加如下内

    复制代码
    #!/bin/bash
    #2345 linux运行级别
    #10开机启动优先级,数值越大越排在前面,最大值100
    #90关机优先级
    #chkconfig:  2345 10 90
    #description: tomcat8080 start....
    start()
    {
        echo 'tomcat8080 start.....'
    #    tomcat 启动shell位置
        sh "/usr/tomcat/bin/startup.sh"
        return     1
    }
    

    stop()
    {
    echo 'tomcat8080 stop.....'
    sh
    "/usr/tomcat/bin/shutdown.sh"
    return 1

    }

    restart()
    {
    stop
    start
    return 1

    }

    case "$1" in
    start)
    start
    exit
    1
    ;;
    stop)
    stop
    exit
    1
    ;;
    restart)
    restart
    exit
    1
    ;;
    *)
    echo
    "no option"
    exit
    1
    ;;
    esac

    复制代码

    修改文件权限

    chmod 755 tomcat8080

    添加到开机启动的服务中

    chkconfig --add tomcat8080

    至于为什么要这样写启动文件

    service 命令会扫描/etc/init.d

    比如 service tomcat8080 start 这个时候运行的是我们自己写的shell,start是参数,tomcat8080文件那样写是为了兼容service命令

    nginx开机启动脚本如下

    复制代码
    #!/bin/bash
    #chkconfig: 2345 10 90
    #description: "nginx80 start...."
    #nginx who use 80 port
    #install direction is /usr/local/nginx
    #start shell is in /usr/local/nginx/sbin
    

    start()
    {
    nginx -c /usr/local/nginx/conf/nginx.conf
    return 1
    }

    stop()
    {
    nginx -s stop
    return 1
    }
    quit()
    {
    nginx
    -s quit
    }
    restart()
    {
    nginx
    -s reload
    return 1
    }
    status()
    {

    no status

    ps -ef | grep nginx

    </span><span style="color: #0000ff;">return</span> 1<span style="color: #000000;">
    

    }

    case $1 in
    start)
    start
    exit
    1
    ;;
    stop)
    stop
    exit
    1
    ;;
    quit)
    quit
    exit
    1
    ;;
    status)
    status
    exit
    1
    ;;
    restart)
    restart
    exit
    1
    ;;
    *)
    echo
    'nginix service no options ' $1
    esac

    复制代码

        Linux下的7个运行级别:

    0系统停机状态,系统默认运行级别不能设置为0,否则不能正常启动,机器关闭。

    1单用户工作状态,root权限,用于系统维护,禁止远程登陆,就像Windows下的安全模式登录。

    2多用户状态,没有NFS支持。

    3完整的多用户模式,有NFS,登陆后进入控制台命令行模式。

    4系统未使用,保留一般不用,在一些特殊情况下可以用它来做一些事情。例如在笔记本电脑的电池用尽时,可以切换到这个模式来做一些设置。

    5X11控制台,登陆后进入图形GUI模式,X Window系统。

    6系统正常关闭并重启,默认运行级别不能设为6,否则不能正常启动。运行init 6机器就会重启。

  • 相关阅读:
    网页一屏到底有多大 1024*768 800*600 网页设计大小 网页设计尺寸
    去掉VS2005中水晶报表的登录界面(ZT)
    Visual Studio 2005 IDE 技巧和窍门
    asp.net大页面载入时以进度条显示zt
    从webservice读取string[]至downlist,增加onchange事件,更改相关显示。
    在asp.net Sql server (可以是存储过程)中使用事务回滚
    得到页面所有的form内对象数值——————为一个控件加一个客户端属性
    Agile Web Development 4th ed. Can't mass assign.error
    Ubuntu12.04中安装和配置Java JDK(转)
    Javascript没有块级作用域
  • 原文地址:https://www.cnblogs.com/jpfss/p/9717057.html
Copyright © 2011-2022 走看看