修改tomcat端口号
tomcat服务器的默认端口号是8080
1 只启动一个tomcat的情况
当我们不想使用8080端口,需要修改为其他端口时,我们可以:
1, 打开tomcat安装目录下的conf目录,找到server.xml文件。
找到以下代码2,修改端口号
上面的8080就是tomcat的对外访问端口, 我们将他修改为其他端口,但是要避免与系统的端口号冲突,选用一个没有使用过的端口号,然后保存退出 如图将端口号修改为80993, 重启tomcat生效
[root@distzabbix tomcat]# netstat -luntp|grep 80tcp6 0 0 127.0.0.1:8005 :::* LISTEN 26201/javatcp6 0 0 :::8009 :::* LISTEN 26201/javatcp6 0 0 :::8080 :::* LISTEN 26201/javatcp6 0 0 :::80 :::* LISTEN 850/httpd[root@distzabbix tomcat]# ./bin/shutdown.shUsing CATALINA_BASE: /usr/share/tomcatUsing CATALINA_HOME: /usr/share/tomcatUsing CATALINA_TMPDIR: /usr/share/tomcat/tempUsing JRE_HOME: /usr/share/jdkUsing CLASSPATH: /usr/share/tomcat/bin/bootstrap.jar:/usr/share/tomcat/bin/tomcat-juli.jar[root@distzabbix tomcat]# ./bin/startup.shUsing CATALINA_BASE: /usr/share/tomcatUsing CATALINA_HOME: /usr/share/tomcatUsing CATALINA_TMPDIR: /usr/share/tomcat/tempUsing JRE_HOME: /usr/share/jdkUsing CLASSPATH: /usr/share/tomcat/bin/bootstrap.jar:/usr/share/tomcat/bin/tomcat-juli.jarTomcat started.[root@distzabbix tomcat]# netstat -luntp|grep 80tcp6 0 0 :::8099 :::* LISTEN 5163/javatcp6 0 0 127.0.0.1:8005 :::* LISTEN 5163/javatcp6 0 0 :::8009 :::* LISTEN 5163/javatcp6 0 0 :::80 :::* LISTEN 850/httpd[root@distzabbix tomcat]#
2 当有多个tomcat时
我们还需修改上面文件的其他两个地方
1,116修改为其他端口,注意避免端口冲突,如下:116
2,
22同样将server port的端口修改为其他端口,注意避免端口冲突,这里我选用18005 22
3,同样重启tomcat
[root@distzabbix tomcat]# netstat -luntp|grep 80tcp6 0 0 127.0.0.1:8005 :::* LISTEN 26201/javatcp6 0 0 :::8009 :::* LISTEN 26201/javatcp6 0 0 :::8080 :::* LISTEN 26201/javatcp6 0 0 :::80 :::* LISTEN 850/httpd[root@distzabbix tomcat]# ./bin/shutdown.shUsing CATALINA_BASE: /usr/share/tomcatUsing CATALINA_HOME: /usr/share/tomcatUsing CATALINA_TMPDIR: /usr/share/tomcat/tempUsing JRE_HOME: /usr/share/jdkUsing CLASSPATH: /usr/share/tomcat/bin/bootstrap.jar:/usr/share/tomcat/bin/tomcat-juli.jar[root@distzabbix tomcat]# ./bin/startup.shUsing CATALINA_BASE: /usr/share/tomcatUsing CATALINA_HOME: /usr/share/tomcatUsing CATALINA_TMPDIR: /usr/share/tomcat/tempUsing JRE_HOME: /usr/share/jdkUsing CLASSPATH: /usr/share/tomcat/bin/bootstrap.jar:/usr/share/tomcat/bin/tomcat-juli.jarTomcat started.[root@distzabbix tomcat]# netstat -luntp|grep 80tcp6 0 0 :::18009 :::* LISTEN 7101/javatcp6 0 0 :::8099 :::* LISTEN 5163/javatcp6 0 0 127.0.0.1:8005 :::* LISTEN 5163/javatcp6 0 0 :::8009 :::* LISTEN 5163/javatcp6 0 0 :::80 :::* LISTEN 850/httpdtcp6 0 0 127.0.0.1:18005 :::* LISTEN 7101/java[root@distzabbix tomcat]#