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 install and configure tomcat and set up automatic startup for Centos7

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the "Centos7 how to install and configure tomcat and set automatic startup" related knowledge, editor through the actual case to show you the operation process, the method of operation is simple and fast, practical, I hope that this "Centos7 how to install and configure tomcat and set up automatic startup" article can help you solve the problem.

What is tomcat?

Tomcat is a servlet container developed by the jakarta project under the apache Software Foundation. According to the technical specifications provided by sun microsystems, it supports servlet and javaserver page (jsp), and provides some unique functions as a web server, such as tomcat management and control platform, security domain management and tomcat valve. Because tomcat itself contains a http server, it can also be considered a separate web server. However, you can't confuse tomcat with an apache http server, which is a httpweb server implemented in c; the two httpweb server are not bundled together. Apache tomcat includes a configuration management tool, which can also be configured by editing a configuration file in xml format.

1. Download the installation package on the official website

Select the installation package suitable for linux, download it locally and upload it to the centos server, or download it directly through the wget command

# cd / usr/local/# mkdir tomcat/# cd tomcat/# wget http://mirrors.cnnic.cn/apache/tomcat/tomcat-9/v9.0.0.m11/bin/apache-tomcat-9.0.0.m11.tar.gz

By doing the above, download the tomcat9 installation package file apache-tomcat-9.0.0.m11.tar.gz to the / usr/local/tomcat directory

2. Install tomcat9

# cd / usr/local/tomcat# tar-zxvf apache-tomcat-9.0.0.m11.tar.gz

The installation package will be unzipped to / usr/local/tomcat/apache-tomcat-9.0.0.m11 and the directory will be renamed tomcat9

# mv / usr/local/tomcat/apache-tomcat-9.0.0.m11 / usr/local/tomcat/tomcat9

Configure the tomcat9 startup environment

# vi / etc/profile.d/tomcat9.shexport catalina_home=/usr/local/tomcat9export path=$tomcat_home/bin:$path# source / etc/profile.d/tomcat9.sh

Use systemd to manage tomcat9 services

# cat / usr/lib/systemd/system/tomcat9.service [unit] description=apache tomcat 9after=syslog.target network.target remote-fs.target nss- lookup.target [service] type=forkingpidfile=/usr/local/tomcat9/tomcat9.pidexecstart=/usr/local/tomcat9/bin/catalina.sh start-deforegrandexecreload=/bin/kill-s hup $mainpidexecstop=/bin/kill-s quit $mainpidremainafterexit= ys [install] wantedby=multi-user.target

3. Configure tomcat9 to boot

Add the tomcat9.service file to the / usr/lib/systemd/system directory as follows:

[unit] description=tomcatafter=syslog.target network.target remote-fs.target nss-lookup.target [service] type=oneshotexecstart=/usr/local/tomcat/tomcat9/bin/startup.shexecstop=/usr/local/tomcat/tomcat9/bin/shutdown.shexecreload=/bin/kill-s hup $mainpidremainafterexit=yes [install] wantedby=multi-user.target

Exit and save, execute systemctl enable tomcat to enable tomcat9 to start with boot

# systemctl enable tomcat9.service

Additional orders

Systemctl start tomcat9.service starts tomcat

Systemctl stop tomcat9.service shuts down tomcat

Systemctl restart tomcat9.service restart tomcat

Of course, starting and ending tomcat can also be done by executing shutdown.sh startup.sh under the bin directory of tomcat's installation directory.

4. Verify that the installation is successful

Enter http:// server ip:8080/

If a familiar tomcat home page appears, it means that the installation is successful. Please make sure that the server port 8080 has been released.

This is the end of the introduction to "how to install and configure tomcat for Centos7 and set up automatic startup". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

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

Development

Wechat

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

12
Report