第一步:
获取>>tomcat下载链接
<<(也可以下载通过xftp等工具上传,上传可跳过第二步)
第二步:
创建存放tomcat压缩包的目录,并在目录下获取tomcat
[root@centos-xy opt]# mkdir tomcat
[root@centos-xy opt]# cd tomcat/
[root@centos-xy tomcat]# wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.62/bin/apache-tomcat-9.0.62.tar.gz
第三步:
将tomcat解压到当前目录下
[root@centos-xy tomcat]# tar zxvf apache-tomcat-9.0.62.tar.gz
第四步:
在/usr/local下创建tomcat目录,解压后的tomcat软件放在该目录下
[root@centos-xy tomcat]# ls
apache-tomcat-9.0.62 apache-tomcat-9.0.62.tar.gz
[root@centos-xy tomcat]# mkdir /usr/local/tomcat
[root@centos-xy tomcat]# mv /opt/tomcat/apache-tomcat-9.0.62 /usr/local/tomcat/
第五步:
(1)进入tomcat目录下获取并复制绝对路径
[root@centos-xy tomcat]# cd /usr/local/tomcat/apache-tomcat-9.0.62/
[root@centos-xy apache-tomcat-9.0.62]# pwd
/usr/local/tomcat/apache-tomcat-9.0.62
(2)配置环境变量
[root@centos-xy apache-tomcat-9.0.62]# vim /etc/profile
(3)在最后面添加tomcat环境变量
# 配置tomcat环境变量
export TOMCAT_HOME=/usr/local/tomcat/apache-tomcat-9.0.62
export CATALINA_HOME=/usr/local/tomcat/apache-tomcat-9.0.62
第六步:
使环境变量生效,检验配置情况
[root@centos-xy apache-tomcat-9.0.62]# source /etc/profile
[root@centos-xy apache-tomcat-9.0.62]# echo $TOMCAT_HOME
/usr/local/tomcat/apache-tomcat-9.0.62
[root@centos-xy apache-tomcat-9.0.62]# echo $CATALINA_HOME
/usr/local/tomcat/apache-tomcat-9.0.62
第七步:
(1)开启8080端口(非云服务器方法)
[root@localhost bin]# firewall-cmd --permanent --add-port=8080/tcp
success
[root@localhost bin]# firewall-cmd --reload
success
(2)云服务只需要开启策防火墙规则可 第八步:
进入tomcat的bin下开启tomcat服务
[root@centos-xy apache-tomcat-9.0.62]# cd bin/
[root@centos-xy bin]# ./startup.sh
Using CATALINA_BASE: /usr/local/tomcat/apache-tomcat-9.0.62
Using CATALINA_HOME: /usr/local/tomcat/apache-tomcat-9.0.62
Using CATALINA_TMPDIR: /usr/local/tomcat/apache-tomcat-9.0.62/temp
Using JRE_HOME: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.322.b06-1.el7_9.x86_64/jre
Using CLASSPATH: /usr/local/tomcat/apache-tomcat-9.0.62/bin/bootstrap.jar:/usr/local/tomcat/apache-tomcat-9.0.62/bin/tomcat-juli.jar
Using CATALINA_OPTS:
Tomcat started.
第九步:
通过ip:8080访问tomcat服务器