Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to deploy Tomcat in Centos

2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to deploy Tomcat in Centos". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to deploy Tomcat in Centos.

Create user sudo useradd-- system-- home / opt/tomcat-- shell / sbin/nologin-- comment "tomcat user"-- user-group tomcat deployment tomcat

Extract the installation package:

Tar-xvf apache-tomcat-9.0.21.tar.gz

Move the decompression package:

Sudo mv apache-tomcat-9.0.21 / opt/tomcat/apache-tomcat-9.0.21

Create a soft link:

Sudo ln-s / opt/tomcat/apache-tomcat-9.0.21 / opt/tomcat/latest

Assign directory user permissions:

Sudo chown-R tomcat: / opt/tomcat

Assign bin directory execution permissions for tomcat:

Sudo sh-c 'chmod + x / opt/tomcat/latest/bin/*.sh' configuration systemd

Check the maximum memory that jvm can use:

Java-Xms16G-Xmx16G-version

Configure the systemd profile:

Vi / etc/systemd/system/tomcat.service

The contents are as follows:

[Unit] Description=Tomcat 9 servlet containerAfter= network.target [service] Type=forkingUser=tomcatGroup=tomcatEnvironment= "JAVA_HOME=/usr/lib/jvm/jre" Environment= "JAVA_OPTS=-Djava.security.egd= file:///dev/urandom"Environment="CATALINA_BASE=/opt/tomcat/latest"Environment="CATALINA_HOME=/opt/tomcat/latest"Environment="CATALINA_PID=/opt/tomcat/latest/temp/tomcat.pid"Environment="CATALINA_OPTS=-Xms16G-Xmx16G-server-XX:+UseParallelGC" ExecStart=/opt/tomcat/latest/bin/startup.shExecStop=/opt/tomcat / latest/bin/ shutdown.sh[Install] WantedBy=multi-user.target

Reload the configuration file:

Sudo systemctl daemon-reload

Enable the configuration and enable the tomcat service:

Sudo systemctl enable tomcat & & sudo systemctl start tomcat

View service status:

Sudo systemctl status tomcat equipped with firewall

Open port 80

Sudo firewall-cmd-zone=public-permanent-add-port=80/tcp

Forward port 80 to port 8080 (ports less than 1024 cannot be accessed by non-root users. Here, the forwarding port feature of the firewall is used to solve this problem):

Sudo firewall-cmd-permanent-add-forward-port=port=80:proto=tcp:toport=8080

Reload the firewall configuration:

Sudo firewall-cmd-reload security

Delete redundant pages:

Cd / opt/tomcat/latest/webappsrm-rf docs examples host-manager manager ROOT

Hide the tomcat version number:

Vim / opt/tomcat/latest/conf/server.xml# add a line: reference

How to install Tomcat 9 on CentOS 7

Firewall-cmd

Nginx hot upgrade

Apache Tomcat 9

Server banner leakage risk

Thank you for reading, the above is the content of "how to deploy Tomcat in Centos". After the study of this article, I believe you have a deeper understanding of how to deploy Tomcat in Centos, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report