赞
踩
Oracle官网下载网址: https://www.oracle.com/java/technologies/javase/jdk11-archive-downloads.html
软件包: jdk-11.0.16_linux-x64_bin.rpm
上传目录推荐: /home/username
#ls /home/username/
jdk-11.0.16_linux-x64_bin.rpm
检查当前系统是否存在 java 环境:
# java -version
若有显示 java 版本信息需要卸载:
# rpm -qa|grep jdk // 检查JDK版本信息
卸载:
# rpm -e --nodeps jdk_???
卸载完后即可安装:
# rpm -ivh jdk-11.0.16_linux-x64_bin.rpm
验证安装:
# rpm -qa|grep jdk
修改配置文件
# vi /etc/profile
...
unset i
unset -f pathmunge
在该文件尾增加以下三行:
# JAVA_HOME
export JAVA_HOME=/usr/java/jdk-11.0.16
export PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/lib //注意是分隔符是":"冒号,不是";"分号,输错后面将导致基本命令执行时报错
使配置文件生效:
# source /rtc/profile
任一目录执行验证:
# java -version
openjdk version "11.0.16" 2022-07-19 LTS
OpenJDK Runtime Environment (Red_Hat-11.0.16.0.8-1.el7_9) (build 11.0.16+8-LTS)
OpenJDK 64-Bit Server VM (Red_Hat-11.0.16.0.8-1.el7_9) (build 11.0.16+8-LTS, mixed mode, sharing)
查看安装的目录
# whereis java
java: /usr/bin/java /usr/share/man/man1/java1
网上所传配置慎用:
export JAVA_HOME=/usr/lib/jvm/jvm/java-11-openjdk-11.0.16.0.8-1.el7_9.x86_64
export JRE_HOME= J A V A H O M E / j r e e x p o r t C L A S S P A T H = JAVA_HOME/jre export CLASSPATH= JAVAHOME/jreexportCLASSPATH=JAVA_HOME/lib: J R E H O M E / l i b : JRE_HOME/lib: JREHOME/lib:CLASSPATH
export PATH= P A T H : PATH: PATH:JAVA_HOME/bin:$JRE_HOME/bin
官网 https://tomcat.apache.org/download-90.cgi, 下载: tar.gz (pgp, sha512) 文件
下载目录推荐: /home/username
# cd /home/username
# tar -zxvf apache-tomcat-9.0.65.tar.gz
# ls
会发现生成 apache-tomcat-9.0.65 目录
# mv apache-tomcat-9.0.65 /usr/local/tomcat9
或在线下载
# wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-9/v9.0.65/bin/apache-tomcat-9.0.65.tar.gz
# tar xzf apache-tomcat-9.0.65.tar.gz
# mv apache-tomcat-9.0.65 /usr/local/tomcat9
# cd /usr/local/tomcat9/
# ./bin/startup.sh
[root@ltgCloudHost tomcat9]# ./bin/startup.sh
Using CATALINA_BASE: /usr/local/tomcat9
Using CATALINA_HOME: /usr/local/tomcat9
Using CATALINA_TMPDIR: /usr/local/tomcat9/temp
Using JRE_HOME: /usr/java/jdk-11.0.16
Using CLASSPATH: /usr/local/tomcat9/bin/bootstrap.jar:/usr/local/tomcat9/bin/tomcat-juli.jar
Using CATALINA_OPTS:
Tomcat started.
最后浏览器中输入 http://localhost:8080
即可访问tomcat服务器了。
[root@ltgCloudHost tomcat9]# firewall-cmd --list-all public target: default icmp-block-inversion: no interfaces: sources: services: dhcpv6-client ssh ports: //`没有开任何端口` protocols: masquerade: no forward-ports: source-ports: icmp-blocks: rich rules: [root@ltgCloudHost tomcat9]# firewall-cmd --list-ports [root@ltgCloudHost tomcat9]# firewall-cmd --zone=public --add-port=8080/tcp --permanent success [root@ltgCloudHost tomcat9]# systemctl restart firewalld [root@ltgCloudHost tomcat9]# firewall-cmd --list-ports 8080/tcp [root@ltgCloudHost tomcat9]# firewall-cmd --list-all public target: default icmp-block-inversion: no interfaces: sources: services: dhcpv6-client ssh ports: 8080/tcp //`己开端口8080` protocols: masquerade: no forward-ports: source-ports: icmp-blocks: rich rules:
<1>. 将 conf/tomcat-users.xml 文件中增加以下几行
<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<user username="admin" password="admin" roles="admin-gui,admin-script,manager-gui,manager-script,manager-jmx,manager-status"/>
<2>. 将 webapps/manager/META-INF/tomcat-users.xml 、webapps/host-manager/META-INF/tomcat-users.xml 内容更改
<!-- // 原内容注释掉换成下面一行
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />
-->
<Valve className="org.apache.catalina.valves.RemoteAddrValve"
allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1|\d+\.\d+\.\d+\.\d+" />
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。