Tomcat8

  • Tomcat 官网

  • 下载

    tomcat-install
    1
    2
    3
    4
    mkdir Tomcat/
    cd Tomcat/
    # tar.gz 的链接
    wget https://downloads.apache.org/tomcat/tomcat-8/v8.5.69/bin/apache-tomcat-8.5.69.tar.gz.asc
  • 解压

    1
    tar -zxvf apache-tomcat-8.5.69.tar.gz
  • 启动测试, 端口号可能会被其他软件使用 ,例如Jenkins 的端口也是8080

    1
    2
    3
    4
    5
    # 进入解压后的目录
    cd apache-tomcat-8.5.69/
    # 查看配置中的端口号
    cd conf/
    vim service.xml
    1
    2
    3
    4
    5
    # service.xml port="8085"
    <Connector port="8085" protocol="HTTP/1.1"
    connectionTimeout="20000"
    redirectPort="8443" />

    1
    2
    3
    4
    5
    6
    7

    # 在购买服务器厂商中开启对应端口号安全组 linux 的防火墙需要关闭,否则不能进行访问链接

    # 进入 bin 目录
    cd bin
    # 启动 Tomcat 注意: linux 启动的是 bin 下的 startup.sh 文件
    ./startup.sh

    | 开启安全组对应端口号 | 启动服务 | 查看 |

| :———————————————————-: | :———————————————————-: | :———————————————————-: |
| tomcatport.png | startTomcat.png | trueTomcat.png |

  • 配置环境变量

    1
    vim /etc/profile
    1
    2
    export CATALINA_HOME=/opt/apache-tomcat-8.5.85
    export PATH=$JAVA_HOME/bin:$CATALINA_HOME/bin:$PATH
    1
    2
    # 生效
    source /etc/profile
  • 静态资源部署测试

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    cd /webapps
    touch index.html
    chmod 777 index.html
    ------------------------
    vim index.html:

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    </head>
    <body>
    <h1> Hello World Tomcat</h1>

    </body>
    </html>
    -------------------------------------

    # 停止服务
    cd bin/
    ./shutdown
    ./startup


    # 静态资源访问路径
    http://101.34.1.228:8085/myweb/index.html

  • 访问

    访问测试

Tomcat10

  • 服务器Tomcat10.x

    • 不要直接下载Tomcat10 在右侧导航栏

      Tomcat10 报错
    • 正确下载

      • 下载

        Tomcat10 下载
      • 启动

        1
        2
        # catalina 比 startup 启动方便查看日志 
        catalina.bat run
        启动 访问测试
        在这里插入图片描述
  • JDK17 + Tomcat10 启动

    JDK17 + Tomcat10 启动