• nginx+tomcat安装配置


    nginx+tomcat安装配置

    # nginx+tomcat安装配置
    
    
    #创建网站目录
    mkdir -p /www/wwwroot
    cd /www
    #安装配置
    wget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-8/v8.5.14/bin/apache-tomcat-8.5.14.tar.gz
    tar -zxvf apache-tomcat-8.5.14.tar.gz
    mv apache-tomcat-8.5.14 tomcat
    rm -rf ./tomcat/
    rm ./tomcat/conf/tomcat-users.*
    cp ./tomcat/conf/server.xml ./tomcat/conf/server.xml.$(date +%Y-%m-%d-%H%M%S).bak
    vim ./tomcat/conf/server.xml
    <Server port="18005"   #关闭Tomcat指令8005,更改端口号
    <Connector port="8009" #注释8009端口,与apache服务集成才需要
    <Connector port="18080" protocol="HTTP/1.1" #web端口8080修改
    <Host name="localhost"  appBase="/www/wwwroot" #appBase="webapps" 路径修改
    mkdir /www/wwwroot/ROOT
    #web 2
    mkdir -p /www/wwwroot2
    mkdir /www/wwwroot2/ROOT
    cp -a tomcat tomcat2
    vim ./tomcat2/conf/server.xml
    <Server port="28005"   #关闭Tomcat指令8005,更改端口号
    <Connector port="28080" protocol="HTTP/1.1" #web端口8080修改
    <Host name="localhost"  appBase="/www/wwwroot2" #appBase="webapps" 路径修改
    #创建测试页
    vim /www/wwwroot/ROOT/index.jsp
    <%@ page language="java" %>
    <html>
      <head><title>ResinA</title></head>
      <body>
        <h1><font color="red">ResinA </font></h1>
        <table align="centre" border="1">
          <tr>
            <td>Session ID</td>
        <% session.setAttribute("abc","abc"); %>
            <td><%= session.getId() %></td>
          </tr>
          <tr>
            <td>Created on</td>
            <td><%= session.getCreationTime() %></td>
         </tr>
        </table>
      </body>
    </html>
    # 测试页2
    vim /www/wwwroot2/ROOT/index.jsp #如上配置,ResinA改为ResinB
    #启动
     /www/tomcat/bin/startup.sh
     /www/tomcat2/bin/startup.sh
    # web 访问 ip:端口18080 28080
    #/usr/local/tomcat/bin/shutdown.sh
    curl localhost:18080
    
    #nginx安装配置
    #http://www.centoscn.com/nginx/2017/0119/8422.html
    rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
    yum install nginx -y
     /usr/sbin/nginx #启动
    cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak0
    #vim /etc/nginx/nginx.conf
    vim  /etc/nginx/conf.d/999.conf #添加测试host  localhost:999
    #------------
     upstream jsweb {
         #ip_hash;
         server localhost:18080;
         server localhost:28080;
     }
    
     server {
         listen 999;
         server_name localhost;
        #index index.jsp;
        access_log                      logs/999.log    main;
        error_log                       logs/999.log     notice;
    
        location / { 
            proxy_pass  http://jsweb;
    
            #Proxy Settings
            proxy_redirect    off;
            proxy_set_header  Host            $host;
            proxy_set_header  X-Real-IP        $remote_addr;
            proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
            proxy_set_header Via "nginx";
            proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
            proxy_max_temp_file_size 0;
            proxy_connect_timeout      90; 
            proxy_send_timeout        90; 
            proxy_read_timeout        90; 
            proxy_buffer_size          4k; 
            proxy_buffers              4 32k;
            proxy_busy_buffers_size    64k;
            proxy_temp_file_write_size 64k;
    
            ## set upload file size
            client_max_body_size 20m; 
     } 
    #------------
    mkdir /etc/nginx/logs
    /usr/sbin/nginx -t #检测配置
    /usr/sbin/nginx -s reload #重启nginx
    /usr/sbin/nginx -s stop #关闭
    #查看日志
    tail -f -n 100 /www/tomcat/logs/catalina.out
    #修改tomcat获取真实ip
    vim /www/tomcat/conf/server.xml
    vim /www/tomcat2/conf/server.xml
      pattern="%h %l %u %t &quot;%r&quot; %s %b" /> #改为如下
      pattern="%{X-Real-IP}i %l %u %t &quot;%r&quot; %s %b" />
      #增加
          <Valve className="org.apache.catalina.valves.RemoteIpValve"  
        internalProxies="127.0.0.1"  
        remoteIpHeader="x-forwarded-for"  
        remoteIpProxiesHeader="x-forwarded-by"  
        trustedProxies="127.0.0.1"/>  
    #重启tomcat
    /www/tomcat/bin/shutdown.sh ; /www/tomcat/bin/startup.sh
    /www/tomcat2/bin/shutdown.sh  ; /www/tomcat2/bin/startup.sh
    
  • 相关阅读:
    table表头固定
    【ztree系列——图标的修改】Bootstrap风格的ztree
    JS使用cookie实现DIV提示框只显示一次的方法
    js正则验证手机号码有效性
    Highcharts、AJAX、JSON、JQuery实现动态数据交互显示图表柱形图
    display:table合并表格
    jsp标签、 项目全路径引用${ctx}
    apache poi合并单元格设置边框
    Kettle 中转换(transformation)的执行过程
    数据结构--堆的实现(上)
  • 原文地址:https://www.cnblogs.com/elvi/p/7718001.html
Copyright © 2020-2023  润新知