Installation of tomcat for CentOS Trample Record

Keywords: Tomcat Java Apache yum

Before installing tomcat, you need to install java first.

Install java package directly with centos, so install java directly with yum is simple and fast.

  • See what jdk versions are available in the yum library (only openjdk is found for the time being)
yum search java|grep jdk
ldapjdk-javadoc.x86_64 : Javadoc for ldapjdk
java-1.6.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.6.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.6.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.6.0-openjdk-javadoc.x86_64 : OpenJDK API Documentation
java-1.6.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.7.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.7.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.7.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.7.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.8.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.8.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.8.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.8.0-openjdk-headless.x86_64 : OpenJDK Runtime Environment
java-1.8.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.8.0-openjdk-src.x86_64 : OpenJDK Source Bundle
ldapjdk.x86_64 : The Mozilla LDAP Java SDK
  • Select the version and install it (I chose 1.8)
yum install java-1.8.0-openjdk
//After installation, the default installation directory is: /usr/lib/jvm/java-1.8.0-openjdk
  • Setting environment variables
vi /etc/profile
  • Add the following to the profile file
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk
# The path of JAVA_HOME must be written correctly here. It's hard to find trouble if you don't meet later.
JRE_HOME=$JAVA_HOME/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH
  • Let the amendment take effect
source /etc/profile

Installation of java is complete.

Start installing tomcat. Use me Last article Method: The tomcat compressed package downloaded by this machine is transferred to the server's / home/ftp/pub directory with filezilla.

  • Switch to the / home/ftp/pub directory. Decompression package
cd /home/ftp/pub/
tar -zxvf apache-tomcat-8.5.16.tar.gz
  • Create a new tomcat directory under / home / to cut in the unzipped folder
mkdir /home/tomcat/
mv /home/ftp/pub/apache-tomcat-8.5.16/ /home/tomcat/
  • Configure Firewall, Open 8080 Port
firewall-cmd --zone=public --add-port=8080/tcp --permanent
firewall-cmd --reload
# If the firewall doesn't open, don't take care of this step.
  • Start tomcat
/home/tomcat/apache-tomcat-8.5.16/bin/startup.sh 

As you can see below, the configuration is OK. But there is no guarantee of full success.

Using CATALINA_BASE:   /home/tomcat/apache-tomcat-8.5.16
Using CATALINA_HOME:   /home/tomcat/apache-tomcat-8.5.16
Using CATALINA_TMPDIR: /home/tomcat/apache-tomcat-8.5.16/temp
Using JRE_HOME:        /home/java/jdk1.8.0_131
Using CLASSPATH:       /home/tomcat/apache-tomcat-8.5.16/bin/bootstrap.jar:/home/tomcat/apache-tomcat-8.5.16/bin/tomcat-juli.jar
Tomcat started.

At this point, test it and use the server to access it directly locally.

curl http://localhost:8080

If no error is reported, the installation is successful. If an error is reported. View tomcat output log

cd /home/tomcat/apache-tomcat-8.5.16/logs/
tail -f catalina.out

See if there is an error in it. Usually an error is reported to cause the local machine to be inaccessible. This mistake is probably the wrong path for JAVA_HOME.
If it's an Aliyun ECS server, it can be accessed with curl command and the external network can't be accessed with ip, maybe it's with me. Last article Finally, there is no access to port 8080 in the cloud server management console in Aliyun. Just set it up as I said in my last article.

Written painstakingly, reproduced please specify the source!

Posted by MentalMonkey on Wed, 22 May 2019 15:48:09 -0700