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

Shell script installs the Tomcat service with one click

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Scripting environment

1.linux centos 7 or redhat 6

two。 The CD image file has been mounted

3. The system is in an environment that can be connected to the external network.

4. Download jdk and tomcat packages first

Baidu Cloud Link

Extraction code: 89be

Experimental procedure

1. Upload the package to the Linux system

two。 Write a script

Vim tomcat.sh

#! / bin/bash

# this is tomcat shell

# turn off the firewall first for enhancement

Systemctl stop firewalld

Setenforce 0

Num1= `env | grep USER | grep root | wc-l `

# determine whether the current user is a root user

If [$num1-ne 0]

Then

Yum-y install gcc gcc-c++

Find-maxdepth 1-name "* .gz" | xargs-i tar xzvf {} & & sleep 1

Mv jdk1.8.0_91/ / usr/local/java

Sed-I'$aJAVA_HOME=/usr/local/java\ nCLASSPATH=$JAVA_HOME/lib\ nPATH=$PATH:$JAVA_HOME/bin\ nexport PATH JAVA_HOME CLASSPATH' / etc/profile

Source / etc/profile

# # #

# change the font color to remind the user that jdk is installed successfully!

Mv apache-tomcat-8.5.16 / usr/local/tomcat8

/ usr/local/tomcat8/bin/startup.sh

Num2= `netstat-anpt | grep ": 8080" | wc-l`

# determine whether the tomcat port is started

If [$num2-ne 0]

Then

Echo-e "\ 033 [32m tomcat install scuess\ 033 [0m"

Else

Echo-e "\ 033 [31m tomcat install fail!\ 033 [0m"

Fi

Else

Echo "not root user, change root user"

Fi

3. Grant authority

Chmod + x tomcat.sh

4. Execute script

. / tomcat.sh

5. View script execution results and verification

reminder

1. To upload tomcat and jdk packages, you can use mount mount or third-party software to upload to Linux. I use xftp, and the package is shared free of charge: link: https://pan.baidu.com/s/1O1yYya7dbIwQdAcao0k4sQ

Extraction code: 40cj

Link to 2.shell script Learning tutorial: "http://www.runoob.com/linux/linux-comm-sed.html""

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

Servers

Wechat

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

12
Report