Tomcat installation and configuration under CentOS 7 (Tomcat startup)

I. Introduction####

What is the scope of this article?
Ready to work?
Environmental information?

Second, the installation process

# 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

Three, configure Tomcat to start up

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

Tomcat installation and configuration under CentOS 7 (Tomcat startup)
Java-JDK installation and configuration under CentOS
CentOS 7 Tomcat service installation and configuration
MySQL 8.0 installation, deployment and configuration under CentOS 6/7
Installation and configuration of redis under centos7
Centos mysql installation and configuration
Centos7 installation and configuration prometheus
CentOS 7 installation and configuration PPTP
CentOS installation and configuration cmake
Centos7.5 installation and configuration MongoDB4.0.4
CentOS 7 installation and configuration PPTP
CentOS 7 installation and configuration graphic tutorials under VMware10
Installation and configuration of rsync server under CentOS 6.5
Environment configuration of JDK, mysql and tomcat under Centos7
Centos7 installation and configuration of Jenkins
Centos7 hadoop cluster installation and configuration
Deploy and optimize Tomcat under Centos
CentOS NTP server installation and configuration
Erlang 20.2 installation and deployment under CentOS 7
Centos7 mysql database installation and configuration
Detailed explanation of Spark installation and configuration tutorial under centOS7
CentOS 7 system installation and configuration graphic tutorial
Installation and use of Mysql under CentOS
Centos7.5 configuration java environment installation tomcat explanation
Zabbix installation and deployment and localization under CentOS
Centos7 hive stand-alone mode installation and configuration
Jenkins installation and deployment tutorial under CentOS 7
KVM installation and preliminary use under CentOS 7.2
DLNA/UPnP Server installation and configuration under Ubuntu 12.04
OpenMPI-Ubuntu installation and configuration
Mysql8.0.15 installation configuration (centos7)
Redis3 installation under Centos7
Installation and configuration of JDK in CentOS 7 system
CentOS 6.5 system installation and configuration graphic tutorial (detailed graphic)
Install svn and configuration through yum under CentOS
Kaldi installation and configuration graphic tutorials under Ubuntu
Installation and configuration of CentOS 7 in VMware Workstation
MySQL 8.0 installation and deployment under CentOS, super detailed!
Installing CentOS 6 and SSH configuration under Windows 8 Hyper-V
MySQL 8.0 installation, deployment and configuration tutorial on CentOS 8
Installation and cracking of confluence6.3 operation records under Centos
Redis cluster installation under CentOS
Installation and cracking of Jira7 operation records under Centos
CentOS6.5 install Java 8 and Tomcat8
Ubuntu16.04 installation and simple configuration
Redis cluster installation under CentOS
centos7 kvm installation and use
CentOS6.5 install Java 8 and Tomcat8
CentOS6.5 install Java 8 and Tomcat8
CentOS7 postgresql installation and use
Centos7 installation tomcat process introduction
Ubuntu PostgreSQL installation and configuration
Centos7 elk7.1.1 installation and use
Introduction to CentOS7 installation process of openjdk, tomcat and mysql
Install and configure keepalived under CentOS 5.9
Use Nginx and u under CentOS
Centos6.5 installation and deployment of KVM
Installation under centos6.9 of jenkins learning
CentOS7 installation and maintenance of Gitlab
Upgrade OpenSSL and OpenSSH under CentOS7
CentOS7.2 and Nginx configuration virtual host