Install tomcat on CentOS 7

Download with wget

First look at what version

 



 Here I choose tomcat 8



 

download:


shell > wget  http://mirror.bit.edu.cn/apache/tomcat/tomcat-8/v8.0.47/bin/apache-tomcat-8.0.47.tar.gz

 

If the download fails, you can use the browser to download and upload it to the Linux server.

 

 

Unzip: 

Unzip here to the /opt/soft path, and unzip it according to your own needs

shell > tar  -zxvf apache-tomcat-8.0.47.tar.gz -C  /opt/soft

 

 

Start tomcat:

shell > cd /opt/soft/apache-tomcat-8.0.47/bin/

shell > ./startup.sh

 

Add port 8080 outside the firewall and restart the
shell > firewall-cmd --zone=public --add-port=8080/tcp --permanent
shell > firewall-cmd --reload

 

illustrate:

--zone scope

--add-port=8080/tcp Add 8080 port, the format is: port/communication protocol

--permanent takes effect permanently, restarting without this parameter will fail

 

 

 

Enter access:




 

Make tomcat a service:

Create a new file tomcat8.service in the /usr/lib/systemd/system/ directory with the following contents

 

Description=Tomcat8  
After=syslog.target network.target remote-fs.target nss-lookup.target  
     
[Service]  
Type=forking  
Environment='JAVA_HOME=/opt/soft/java/jdk1.8.0_151'  
Environment='CATALINA_PID=/opt/soft/tomcat/apache-tomcat-8.0.47/bin/tomcat.pid'  
Environment='CATALINA_HOME=/opt/soft/tomcat/apache-tomcat-8.0.47/'  
Environment='CATALINA_BASE=/opt/soft/tomcat/apache-tomcat-8.0.47/'  
Environment='CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC'  
  
WorkingDirectory=/opt/soft/tomcat/apache-tomcat-8.0.47/  
  
ExecStart=/opt/soft/tomcat/apache-tomcat-8.0.47/bin/startup.sh  
ExecReload=/bin/kill -s HUP $MAINPID  
ExecStop=/bin/kill -s QUIT $MAINPID  
PrivateTmp=true  
     
[Install]  
WantedBy=multi-user.target  

 

 

then you can pass 

A, start the service: systemctl start tomcat7

B, stop the service: systemctl stop tomcat7

C, restart the service: systemctl restart tomcat7

 

Check status: systemctl status tomcat7

 

These operations are performed to start and stop tomcat.

 

Set to boot up: systemctl enable tomcat7

 

 

 

 

 

 

 

 Set the environment variables of tomcat:

First, let's configure the environment variables and memory settings of tomcat. After entering the bin directory of tomcat, open the catalina.sh file through the vi command, and add the following configuration to it:

JAVA_OPTS="-Xms512m -Xmx1024m -Xss1024K -XX:PermSize=512m -XX:MaxPermSize=1024m"
export TOMCAT_HOME=/wocloud/tomcat_cluster/tomcat1/apache-tomcat-7.0.57
export CATALINA_HOME=/wocloud/tomcat_cluster/tomcat1/apache-tomcat-7.0.57
export JRE_HOME=/wocloud/java/jdk1.7.0_75/jre
export JAVA_HOME=/wocloud/java/jdk1.7.0_75

 

 

 

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326154241&siteId=291194637