zoukankan      html  css  js  c++  java
  • 修改tomcat默认端口号8080

    修改tomcat端口号

    tomcat服务器的默认端口号是8080

    1 只启动一个tomcat的情况

    当我们不想使用8080端口,需要修改为其他端口时,我们可以:

    1, 打开tomcat安装目录下的conf目录,找到server.xml文件。
    找到以下代码

        <Connector port="8080" protocol="HTTP/1.1"
                   connectionTimeout="20000"
                   redirectPort="8443" />

    2,修改端口号
    上面的8080就是tomcat的对外访问端口,
    我们将他修改为其他端口,但是要避免与系统的端口号冲突,选用一个没有使用过的端口号,然后保存退出
    如图将端口号修改为8099

        <Connector port="8099" protocol="HTTP/1.1"
                   connectionTimeout="20000"
                   redirectPort="8443" />
    

    3, 重启tomcat生效

    [root@distzabbix tomcat]# netstat -luntp|grep 80
    tcp6       0      0 127.0.0.1:8005          :::*                    LISTEN      26201/java
    tcp6       0      0 :::8009                 :::*                    LISTEN      26201/java
    tcp6       0      0 :::8080                 :::*                    LISTEN      26201/java
    tcp6       0      0 :::80                   :::*                    LISTEN      850/httpd
    [root@distzabbix tomcat]# ./bin/shutdown.sh
    Using CATALINA_BASE:   /usr/share/tomcat
    Using CATALINA_HOME:   /usr/share/tomcat
    Using CATALINA_TMPDIR: /usr/share/tomcat/temp
    Using JRE_HOME:        /usr/share/jdk
    Using CLASSPATH:       /usr/share/tomcat/bin/bootstrap.jar:/usr/share/tomcat/bin/tomcat-juli.jar
    [root@distzabbix tomcat]# ./bin/startup.sh
    Using CATALINA_BASE:   /usr/share/tomcat
    Using CATALINA_HOME:   /usr/share/tomcat
    Using CATALINA_TMPDIR: /usr/share/tomcat/temp
    Using JRE_HOME:        /usr/share/jdk
    Using CLASSPATH:       /usr/share/tomcat/bin/bootstrap.jar:/usr/share/tomcat/bin/tomcat-juli.jar
    Tomcat started.
    [root@distzabbix tomcat]# netstat -luntp|grep 80
    tcp6       0      0 :::8099                 :::*                    LISTEN      5163/java
    tcp6       0      0 127.0.0.1:8005          :::*                    LISTEN      5163/java
    tcp6       0      0 :::8009                 :::*                    LISTEN      5163/java
    tcp6       0      0 :::80                   :::*                    LISTEN      850/httpd
    [root@distzabbix tomcat]#
    2 当有多个tomcat时

    我们还需修改上面文件的其他两个地方
    1,

    116 <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
    
    修改为其他端口,注意避免端口冲突,如下:
    116 <Connector port="18009" protocol="AJP/1.3" redirectPort="8443" />

    2,

     22 <Server port="8005" shutdown="SHUTDOWN">
    同样将server port的端口修改为其他端口,注意避免端口冲突,这里我选用18005
     22 <Server port="18005" shutdown="SHUTDOWN">

    3,同样重启tomcat

    [root@distzabbix tomcat]# netstat -luntp|grep 80
    tcp6       0      0 127.0.0.1:8005          :::*                    LISTEN      26201/java
    tcp6       0      0 :::8009                 :::*                    LISTEN      26201/java
    tcp6       0      0 :::8080                 :::*                    LISTEN      26201/java
    tcp6       0      0 :::80                   :::*                    LISTEN      850/httpd
    [root@distzabbix tomcat]# ./bin/shutdown.sh
    Using CATALINA_BASE:   /usr/share/tomcat
    Using CATALINA_HOME:   /usr/share/tomcat
    Using CATALINA_TMPDIR: /usr/share/tomcat/temp
    Using JRE_HOME:        /usr/share/jdk
    Using CLASSPATH:       /usr/share/tomcat/bin/bootstrap.jar:/usr/share/tomcat/bin/tomcat-juli.jar
    [root@distzabbix tomcat]# ./bin/startup.sh
    Using CATALINA_BASE:   /usr/share/tomcat
    Using CATALINA_HOME:   /usr/share/tomcat
    Using CATALINA_TMPDIR: /usr/share/tomcat/temp
    Using JRE_HOME:        /usr/share/jdk
    Using CLASSPATH:       /usr/share/tomcat/bin/bootstrap.jar:/usr/share/tomcat/bin/tomcat-juli.jar
    Tomcat started.
    [root@distzabbix tomcat]# netstat -luntp|grep 80
    tcp6       0      0 :::18009                :::*                    LISTEN      7101/java
    tcp6       0      0 :::8099                 :::*                    LISTEN      5163/java
    tcp6       0      0 127.0.0.1:8005          :::*                    LISTEN      5163/java
    tcp6       0      0 :::8009                 :::*                    LISTEN      5163/java
    tcp6       0      0 :::80                   :::*                    LISTEN      850/httpd
    tcp6       0      0 127.0.0.1:18005         :::*                    LISTEN      7101/java
    [root@distzabbix tomcat]#
  • 相关阅读:
    第二周编程总结
    介绍自己
    编程总结3
    PTA编程总
    PTA编程总结1
    《秋季学期学习总结》
    《人生路上对我影响最大的三位老师》
    介绍自己
    7-1 打印沙漏
    记叙在人生路上对你影响最大的三位老师
  • 原文地址:https://www.cnblogs.com/wzstudy/p/10690656.html
Copyright © 2011-2022 走看看