阿里云平台yum安装java、tomcat,配置80到8080端口重定向,设置通过IP或域名访问tomcat项目 实战总结【包括centos7版本防火墙Firewalls配置;8080端口号修改;tomcat 80 端口报错重定向8080配置;设置tomcat直接访问项目目录设置】
1.yum 安装java
yum install -y java
Java版本信息:
[root@centos7 ~]# java -version
openjdk version "1.8.0_201"
OpenJDK Runtime Environment (build 1.8.0_201-b09)
OpenJDK 64-Bit Server VM (build 25.201-b09, mixed mode)
java 默认安装目录
[root@centos7 jvm]# pwd
/usr/lib/jvm
[root@centos7 jvm]# ll
total 8
drwxr-xr-x 4 root root 4096 Apr 20 23:01 java-1.7.0-openjdk-1.7.0.211-2.6.17.1.el7_6.x86_64
drwxr-xr-x 3 root root 4096 Apr 12 12:30 java-1.8.0-openjdk-1.8.0.201.b09-2.el7_6.x86_64
lrwxrwxrwx 1 root root 21 Apr 20 23:01 jre -> /etc/alternatives/jre
lrwxrwxrwx 1 root root 27 Apr 20 23:01 jre-1.7.0 -> /etc/alternatives/jre_1.7.0
lrwxrwxrwx 1 root root 35 Apr 20 23:01 jre-1.7.0-openjdk -> /etc/alternatives/jre_1.7.0_openjdk
lrwxrwxrwx 1 root root 54 Apr 20 23:01 jre-1.7.0-openjdk-1.7.0.211-2.6.17.1.el7_6.x86_64 -> java-1.7.0-openjdk-1.7.0.211-2.6.17.1.el7_6.x86_64/jre
lrwxrwxrwx 1 root root 27 Apr 12 12:30 jre-1.8.0 -> /etc/alternatives/jre_1.8.0
lrwxrwxrwx 1 root root 35 Apr 12 12:30 jre-1.8.0-openjdk -> /etc/alternatives/jre_1.8.0_openjdk
lrwxrwxrwx 1 root root 51 Apr 12 12:30 jre-1.8.0-openjdk-1.8.0.201.b09-2.el7_6.x86_64 -> java-1.8.0-openjdk-1.8.0.201.b09-2.el7_6.x86_64/jre
lrwxrwxrwx 1 root root 29 Apr 20 23:01 jre-openjdk -> /etc/alternatives/jre_openjdk
2.yum 安装 tomcat
yum iinstall -y tomcat
Tomcat版本信息:
[root@centos7 ~]# /usr/sbin/tomcat version
Server version: Apache Tomcat/7.0.76
Server built: Mar 12 2019 10:11:36 UTC
Server number: 7.0.76.0
OS Name: Linux
OS Version: 3.10.0-957.10.1.el7.x86_64
Architecture: amd64
JVM Version: 1.8.0_201-b09
JVM Vendor: Oracle Corporation
tomcat 默认安装目录:
[root@centos7 ~]# cd /usr/share/tomcat/
[root@centos7 tomcat]# ll
total 4
drwxr-xr-x 2 root root 4096 Apr 20 22:35 bin
lrwxrwxrwx 1 root tomcat 11 Apr 20 22:35 conf -> /etc/tomcat
lrwxrwxrwx 1 root tomcat 22 Apr 20 22:35 lib -> /usr/share/java/tomcat
lrwxrwxrwx 1 root tomcat 15 Apr 20 22:35 logs -> /var/log/tomcat
lrwxrwxrwx 1 root tomcat 22 Apr 20 22:35 temp -> /var/cache/tomcat/temp
lrwxrwxrwx 1 root tomcat 23 Apr 20 22:35 webapps -> /var/lib/tomcat/webapps
lrwxrwxrwx 1 root tomcat 22 Apr 20 22:35 work -> /var/cache/tomcat/work
[root@centos7 tomcat]#
至此 tomcat,Java 安装完成
3.问题:项目需要挂到公网访问
3.1 解决思路一:错误配置:
====================================