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 here.java -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
Java-version
#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 https://tomcat.apache.org/download-90.cgi page; Select Download core (kernel) under binary distributions (binary release) Zip or tar.gz compressed file below; Select tar.gz here

Wget-c http://ftp.cuhk.edu.hk/pub/packages/apache.org/tomcat/tomcat-9/v9.0.12/bin/apache-tomcat-9.0.12.tar.gz

#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/catalina.sh

Ln-s/home/tomcat/bin/catalina.sh/etc/init.d/tomcat

Add the/home/tomcat directory to an environment variable

Vi/etc/profile
Export Catalina_home=/home/tomcat
Source/etc/profile

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/catalina.sh start-security
Or
Sudo-u Tomcat/etc/init.d/tomcat start-security
Or
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
Mkdir-p/home/tomcat/lib/org/apache/catalina/util
Vi/home/tomcat/lib/org/apache/catalina/util/serverinfo.properties Add the following:
Server.info=version
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/catalina.sh 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: info-contact@alibabacloud.com 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.