# Open download directory
cd /home/download
# Download the tar package
wget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-8/v8.5.24/bin/apache-tomcat-8.5.24.tar.gz
Download address of Tomcat7 official website: https://tomcat.apache.org/download-70.cgi
Download address of Tomcat8 official website: https://tomcat.apache.org/download-80.cgi
# Create tomcat directory
sudo mkdir /usr/tomcat
# Unzip to the specified directory
sudo tar -zvxf apache-tomcat-8.5.24.tar.gz -C /usr/tomcat
# Rename the directory to tomcat8
mv /usr/tomcat/apache-tomcat-8.5.24/usr/tomcat/tomcat8
If the system default JDK version is JDK 1.8.x, you can omit this step
If multiple Tomcats need to be deployed in the system, for example: Tomcat 7+JDK 7, Tomcat 8 + JDK 8 coexist then the following configuration is required:
The default Java version of the machine can be viewed through the command java -version
1、 Modify catalina.sh file
# Modify catalina.sh
vi /usr/tomcat/tomcat8/bin/catalina.sh
# Add the following configuration:
export JAVA_HOME=/usr/java/jdk1.8.0_151
2、 Modify the setclasspath.sh file
# Modify setclasspath.sh
vi /usr/tomcat/tomcat8/bin/setclasspath.sh
# Add the following configuration:
export JAVA_HOME=/usr/java/jdk1.8.0_151
Among them, /usr/java/jdk1.8.0_151 is because the server JDK8 tested by ken.io is in this directory
, Replace it with the jdk directory of the server during actual deployment
Non-essential operation, if you need to deploy multiple Tomcats, you need to modify the port
# Modify server.xml
vi /usr/tomcat/tomcat8/conf/server.xml
Find the following line, Tomcat default port is 8080, modify it according to your needs
< Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"/>
# Open port 8080
firewall-cmd --add-port=8080/tcp --permanent && firewall-cmd --reload
# Reload firewall rules
firewall-cmd --reload
# start up
cd /usr/tomcat/tomcat8/bin && sh startup.sh
# Deactivate
cd /usr/tomcat/tomcat8/bin && sh shutdown.sh
Access ip through browser: 8080
It is very simple to configure Tomcat to start up, just configure Tomcat as a system service.
# Create Tomcat8 service file
vi /usr/lib/systemd/system/tomcat8.service
# tomcat8.Service file content:
[ 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
# Set Tomcat8 to boot
systemctl enable tomcat8
# Start tomcat8 service
systemctl start tomcat8
Recommended Posts