categories: [Tomcat8,Centos 7]
tags: [Tomcat8,Centos 7] ##
**I use centos7X64 to install minimally **CentOS-7-x86_64-Minimal-1708
Students who have not installed jdk, please move to the article of [centos7 install jdk8 in the correct posture and set the boot autostart] article
Either turn off the firewall or join the release port
systemctl stop firewalld.service #Stop firewall
systemctl disable firewalld.service #Prohibit firewall startup
firewall-cmd --state #View the default firewall status (notrunning will be displayed after it is turned off, and running)
[ root@localhost ~]# firewall-cmd --state
not running
[ root@localhost ~]#
firewall-cmd --zone=public--add-port=80/tcp --permanent #Add release port(--permanent takes effect permanently, it will become invalid after restart without this parameter)
firewall-cmd --reload #Refresh the firewall to take effect
firewall-cmd --zone=public--list-ports #View the firewall release port list
[ root@localhost ~]# firewall-cmd --zone=public--add-port=8080/tcp --permanent #(--permanent takes effect permanently, after restarting without this parameter.effect)
success
[ root@localhost ~]# firewall-cmd --reload
success
[ root@localhost ~]# firewall-cmd --zone=public--list-ports
80 /tcp 8080/tcp
[ root@localhost ~]#
Indicates success
yum -y install wget
wget http://mirrors.shuosc.org/apache/tomcat/tomcat-8/v8.5.42/bin/apache-tomcat-8.5.42.tar.gz
If it fails, check the download address on the official website yourself, or use the official original software I provided below
If the source address is invalid, use the Baidu cloud disk link to download and upload to the server yourself
Link: apache-tomcat-8.5.24.tar.gz official original Extraction code: y3hu
tar -zxvf apache-tomcat-8.5.42.tar.gz
mv apache-tomcat-8.5.42/usr/local/tomcat8
yum -y install vim
vim /usr/local/tomcat8/bin/catalina.sh
Add the following code in front of OS specific support.:
export JAVA_HOME=/usr/local/java/jdk1.8.0_211
export JRE_HOME=$JAVA_HOME/jre
Add the tomcat8.service file in the /usr/lib/systemd/system directory, the content is as follows:
vi /usr/lib/systemd/system/tomcat8.service
[ Unit]
Description=Tomcat-8
After=syslog.target network.target remote-fs.target nss-lookup.target
[ Service]
Type=oneshot
ExecStart=/usr/local/tomcat8/bin/startup.sh
ExecStop=/usr/local/tomcat8/bin/shutdown.sh
ExecReload=/bin/kill -s HUP $MAINPID
RemainAfterExit=yes
[ Install]
WantedBy=multi-user.target
systemctl enable tomcat8
systemctl enable tomcat.service //Boot tomcat
systemctl disable tomcat.service //Disable boot tomcat
systemctl start tomcat8.service //Start tomcat
systemctl stop tomcat8.service //Close tomcat
systemctl restart tomcat8.service //Restart tomcat
systemctl status tomcat8.service //View status tomcat
Recommended Posts