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 solve the problem of Ubuntu installing Tomcat and configuring systemctl management

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article "Ubuntu installation Tomcat and configuration systemctl management problem how to solve" most people do not understand the knowledge points of the article, so Xiaobian summarized the following content for everyone, detailed content, clear steps, with a certain reference value, I hope you can read this article to gain something, let's take a look at this article "Ubuntu installation Tomcat and configuration systemctl management problem how to solve" article bar.

software environment

Ubuntu Server 18.04.1 LTS

JDK version: Java SE Development Kit 8u231

Tomcat Version: Tomcat 9.0.27 Released

1. download and install

Because JDK download requires login, it is inconvenient to download with wget. It is recommended to download it on another machine first and then copy it to Ubuntu.

Extract the downloaded JDK package to the specified directory

tar -zxvf jdk-8u231-linux-x64.tar.gz -C ~/server

The requested URL/home/ubuntu/server/jdk1.8.0_231 was not found on this server.

PS: Due to Linux permissions issues, it is recommended that JDK be installed in a directory that does not require root privileges. I created the server directory at home.

2. Configuring JDK Environment Variables

If vim is not installed, it needs to be installed first.

sudo apt-get install vim

Editing environment variable files with vim

sudo vi /etc/profile

Add JDK environment variables at the end of the file

#set Java environmentexport JAVA_HOME=/home/ubuntu/server/jdk1.8.0_231export JRE_HOME=$JAVA_HOME/jreexport CLASSPATH=.:$ JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATHexport PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

for the environment variables to take effect

source /etc/profile

View JDK version

java -version#Results java version "1.8.0_231"Java(TM) SE Runtime Environment (build 1.8.0_231-b11)Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)

2 Download and install Tomcat

Tomcat download does not require login, you can download directly with wget

wget https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-9/v9.0.27/bin/apache-tomcat-9.0.27.tar.gz

Extract to specified directory

tar -zxvf apache-tomcat-9.0.27.tar.gz ~/server

The requested URL/home/ubuntu/server/apache-tomcat-9.0.27 was not found on this server.

PS: Many tutorials on the Internet say that you need to configure environment variables for Tomcat, but you don't need them at all.

3 Configuring systemctl to manage Tomcat services

1. Create setenv.sh file in tomcat bin directory

vi ~/server/apache-tomcat-9.0.27/bin/setenv.sh#setenv.sh file content CATALINA_PID="$CATALINA_BASE/tomcat.pid"

2. Add tomcat.service file

sudo vi /lib/systemd/system/tomcat.service#tomcat.service File Content [Unit]Description=TomcatAfter=network.target remote-fs.target sy. target [Service]Type=forkingPIDFile=/home/ubuntu/server/apache-tomcat-9.0.27/tomcat. pidExecuStart =/home/ubuntu/server/apache-tomcat-9.0.27/bin/startup. shExecuReload =/bin/kill -s HUP $MAINPIDExecuStop =/bin/kill -s QUIT $MAINPIDPrivateTmp=true[Install]WantedBy=multi-user.target

3. overloaded systemctl daemon

#overload daemon systemctl daemon-reload#start service sudo systemctl start tomcat#stop service sudo systemctl stop tomcat#restart service sudo systemctl restart tomcat#boot self startup sudo systemctl enable tomcat#cancel self startup sudo systemctl disable tomcat

2019.11.13 supplementary

Neither the JAVA_HOME nor the JRE_HOME environment variable is defined, java environment variable configuration is normal, but that is to say, it cannot be found.

Solution: Add java environment variables at the top of bin/ setclasspath.sh file under Tomcat directory

export JAVA_HOME=/home/ubuntu/server/jdk1.8.0_231export JRE_HOME=$JAVA_HOME/jre The above is about "how to solve the problem of installing Tomcat and configuring systemctl management in Ubuntu" The content of this article, I believe everyone has a certain understanding, I hope the content shared by Xiaobian is helpful to everyone, if you want to know more related knowledge content, please pay attention to the industry information channel.

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