CentOS7部署Tomcat服务器

1. 软件

存放路径:/usr/local/src
apache-tomcat-9.0.22.tar.gz
openjdk-12_linux-x64_bin.tar.gz

2.事先配置

启动后关闭防火墙,关闭selinux

3.配置java

3.1 解压缩到指定目录并重命名

tar -zxv -f openjdk-12_linux-x64_bin.tar.gz -C /usr/local/
cd /usr/local/
mv jdk-12/ java

3.2 建立java.sh脚本

cd /etc/profile.d/
vim java.sh
export JAVA_HOME=/usr/local/java
export PATH=$PATH:$JAVA_HOME/bin

3.3 java.sh脚本导入到环境变量,使其生效

source java.sh

3.4 查看版本

java -version

4. 配置tomcat

4.1 解压缩到指定目录并重命名

tar -zxv -f apache-tomcat-9.0.22.tar.gz -C /usr/local/
cd /usr/local/
mv apache-tomcat-9.0.22/ tomcat9

4.2 启动tomcat

# /usr/local/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/local/java
Using CLASSPATH:       /usr/local/tomcat9/bin/bootstrap.jar:/usr/local/tomcat9/bin/tomcat-juli.jar
Tomcat started.

检查端口

# netstat -ntap | grep 8080

4.3 访问

打开浏览器,输入地址:http://ip:8080

4.4 关闭tomcat

# /usr/local/tomcat9/bin/shutdown.sh 
Using CATALINA_BASE:   /usr/local/tomcat9
Using CATALINA_HOME:   /usr/local/tomcat9
Using CATALINA_TMPDIR: /usr/local/tomcat9/temp
Using JRE_HOME:        /usr/local/java
Using CLASSPATH:       /usr/local/tomcat9/bin/bootstrap.jar:/usr/local/tomcat9/bin/tomcat-juli.jar
NOTE: Picked up JDK_JAVA_OPTIONS:  --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
posted @ 2019-08-12 17:17  哈喽哈喽111111  阅读(1131)  评论(0编辑  收藏  举报