Install Tomcat7 under centOS6.4

foreword

Record  the complete steps to install Tomcat7 on Linux  CentOS 7.

download

First, you need to download the installation file of tomcat7, the address is as follows:  http://mirror.bit.edu.cn/apache/tomcat/tomcat-7/v7.0.69/bin/apache-tomcat-7.0.69.tar.gz

installation and configuration

Before installation, you need to ensure that JDK has been installed . If JDK is not installed, please refer to the previous blog to install JDK correctly:  Linux CentOS 7 & JDK 1.7 Installation and Configuration , if JDK has been installed, then you can install tomcat next. Upload the downloaded installation file to the corresponding directory of the Linux server. The first step is to unzip it:

tar -zxvf apache-tomcat- 7.0.57.tar.gz

After decompression is complete, delete the installation package:

rm -rf apache-tomcat-7.0.57.tar.gz

Considering to do a tomcat cluster later , create a new directory and move the decompressed tomcat into it:

mkdir /wocloud/tomcat_cluster/

mkdir /wocloud/tomcat_cluster/tomcat1

mv ./apache-tomcat-7.0.57//wocloud/tomcat_cluster/tomcat1/ 

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.57export CATALINA_HOME=/wocloud/tomcat_cluster/tomcat1/apache-tomcat-7.0.57export JRE_HOME=/wocloud/java/jdk1.7.0_75/jreexport JAVA_HOME=/wocloud/java/jdk1.7.0_75

 

 

The effect diagram is as follows:  

 
Next, modify the port number of tomcat, enter the conf directory of tomcat, modify the server.xml file, open the file through the vi command and directly enter /8080 to retrieve the location of the port number, enter the edit mode and modify the port number as 8081, as shown in the following figure: 

 
Finally, enter : wq to save and exit.

Next we can try to start tomcat, switch to the bin directory of tomcat and enter the startup command:

./startup.sh

If you see the following prompt, it means that the startup has been successful:

 
OK, let's try to access it through another windows server on the intranet:

 
unfortunately, it cannot be accessed, but there is no problem with the port number. What is the reason for this? ? The reason is that compared with windows, linux has a stronger security mechanism, and a more powerful firewall, Firewall, was introduced in CentOS 7. We need to open port 8081 in Firewall, that is, add port 8081 to zone (a new feature of Firewall, simply speaking, its function is to define the trust level of network connection in the network area). The command is as follows:

firewall-cmd--zone=public--add-port=8081/tcp--permanent   

In this way, port 8081 is successfully added to the public area. The permanent parameter indicates that it will take effect permanently, that is, restarting will not fail. Finally, don't forget to update the firewall rules:

firewall-cmd--reload 

OK, let's take a look at all the opened ports in the public area, the command is as follows:

firewall-cmd--zone=public--list-ports  

You can see that port 8081 has been successfully opened: 

 
visit tomcat again to see the result: 



 
Good, successfully saw the familiar Tom cat, and the installation has been successfully completed so far.

Summarize

Briefly record the whole process of installing tomcat7 in Linux CentOS 7, I hope to help friends who encounter the same problem, The End.

Guess you like

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