Record CentOS Installation Tomcat9

Source: Internet
Author: User

(1) Installing the Java Operating environment

Yum-y Update
Yum Search Java
#There will be java related packages -1.8.0-OPENJDK.X86_64:OPENJDK Runtime Environment
Yum-y Install java-1.8.0-openjdk.x86_64
Yum-y Install java-1.8.0-openjdk-devel.x86_64
#openjdk Version "1.8.0_181"
#OpenJDK Runtime Environment (build 1.8.0_181-b13)
#OpenJDK 64-bit Server VM (build 25.181-b13, Mixed mode)

(2) Installation Tomcat9

Add a user group
Groupadd Tomcat
Add a user tomcat and assign to the group Tomcat, set its home directory to/home/tomcat, and this user is a non-logged on user
Useradd-s/bin/nologin-g tomcat-d/home/tomcat Tomcat

Go to the page; Select Download core (kernel) under binary distributions (binary release) Zip or tar.gz compressed file below; Select tar.gz here


#apache-tomcat-9.0.12.tar.gz the contents into the/home/tomcat.

TAR-ZXVF apache-tomcat-9.0.12.tar.gz-c/home/tomcat--strip-components 1 The #-c option is to specify the directory that needs to be extracted. --strip-components 1 Extract Next Level directory

Generate links for/home/tomcat/bin/


Add the/home/tomcat directory to an environment variable

Export Catalina_home=/home/tomcat

The Tomcat user that configures the own permissions of the directory/home/tomcat/to the Tomcat group

Chown-r tomcat:tomcat/home/tomcat/

Now it can be started by/etc/init.d/tomcat, as follows

Sudo-u tomcat/home/tomcat/bin/ start-security
Sudo-u Tomcat/etc/init.d/tomcat start-security
Sudo-u Tomcat service Tomcat Start-u security
Remember to specify a tomcat user to boot to prevent Tomcat from deleting things from your entire hard drive

After Tomcat starts, it is possible to view the Tomcat listener's port as 8009: Port 8080:web Access Port 8005, which may be used with other HTTP integrations: Listen to the port of Tomcat shut down

Netstat-napt |grep java |grep LISTEN

(3) Tomcat9 Simple security settings

1, hidden version number
Vi/home/tomcat/lib/org/apache/catalina/util/ Add the following:
And then reboot Tomcat to do it.

2. Modify/home/tomcat/conf/server.xml <server port= "8005" shutdown= "shutdown" > Port value and shutdown value in this configuration PORT Specifies a string that specifies the Tomcat listener shutdown command ports, shutdown specifies the shutdown listener port that is sent to the Tomcat server when the Tomcat server is running, and for security reasons. Do not use default values, as modified to the following content

<server port= "8303" shutdown= "God_bless_me_have_no_longer_bug" >
Remember to change the situation when you do not start Tomcat

3, in their own web should try to replace the default 404,403,500 page

4, try to add-security after starting the script to increase security management;

/home/tomcat/bin/ start-security

5. Try not to start Tomcat with the root user

Record CentOS Installation Tomcat9

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.