CentOS 7下安装配置Tomcat
环境:CentOS 7.9
Tomcat下载地址:http://down.cnaaa.net/static/upload/other/20220802/1659432295529455.rar
安装rz工具
yum -y install lrzsz
创建Tomcat目录
mkdir /usr/tomcat
通用rz工具,将安装包上传
解压文件
tar -zvxf apache-tomcat-8.5.81.tar.gz
修改目录名Tomcat8
mv /usr/tomcat/apache-tomcat-8.5.81 /usr/tomcat/tomcat8
没有JDK安装JDK
yum install java-1.8.0-openjdk*
目录在/usr/lib/jvm
Tomcat指定JDK配置
修改catalina.sh文件
vi /usr/tomcat/tomcat8/bin/catalina.sh
增加一行
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.342.b07-1.el7_9.x86_64\
修改setclasspath.sh文件
vi /usr/tomcat/tomcat8/bin/setclasspath.sh
增加一行
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.342.b07-1.el7_9.x86_64\
Tomcat端口修改
修改端口,默认端口8080
vi /usr/tomcat/tomcat8/conf/server.xml
防火墙放行端口
开放8080
firewall-cmd --add-port=8080/tcp --permanent && firewall-cmd --reload
重新加载防火墙
firewall-cmd --reload
启动关闭Tomcat
cd /usr/tomcat/tomcat8/bin && sh startup.sh //启动
cd /usr/tomcat/tomcat8/bin && sh shutdown.sh //关闭
测试(IP地址:端口号)
Tomcat开机自启
vi /usr/lib/systemd/system/tomcat8.service
[Unit]
Description=Tomcat8
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/usr/tomcat/tomcat8/bin/startup.sh
ExecReload=/usr/tomcat/tomcat8/bin/startup.sh
ExecStop=/usr/tomcat/tomcat8/bin/shutdown.sh
[Install]
WantedBy=multi-user.target
配置开机启动
systemctl enable tomcat8
systemctl start tomcat8
文章来源:https://www.cnaaa.net,转载请注明出处:https://www.cnaaa.net/archives/5647