Linux - install JDK, Tomcat and Docker

Linux (VIII) -- install JDK, Tomcat and Docker

There are generally three ways to install software:

  • rpm: use the rpm command to install the package with the extension ". rpm"
  • decompression
  • Install online using yum or up2date

1. rpm install JDK and publish project

1. Official website download address: https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html

2. Use xftp file transfer to transfer the downloaded jdk to the Linux server

3. Install the jdk using the command

[root@cheng java]# rpm ivh jdk-8u301-linux-x64.rpm 

Force deletion of jdk

[root@cheng java]# rpm -e --nodeps jdk1.8.0_121-1.8.0_121-fcs.x86_64

4. Configure environment variables

Open = = / etc/profile = = file with vim editor, command: vim /etc/profile

Press i to switch the input mode and add the following configuration:

JAVA_HOME=/usr/java/jdk1.8.0_301-amd64
JRE_HOME=$JAVA_HOME/jre
CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib
PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
export JAVA_HOME JRE_HOME CLASSPATH PATH

# Save exit
:wq
# Make the new environment variable effective!
source /etc/profile

Publish project

Release a Spring Boot project

1. Package the project

2. Transfer the packaged spring boot project to the Linux server

3. You need to open the port before publishing the project

  1. To see which ports are already open:

    firewall-cmd --list-ports
    

  1. Turn on the firewall
#View firewall status
firewall-cmd --state

#Turn on the firewall
systemctl start firewalld
  1. Open the 9001 port required for the project. If it is an alicloud server, you also need to open the port number in the security group.
firewall-cmd --zone=public --add-port=9001/tcp --permanent
  1. service iptables restart

    firewall-cmd --reload
    

4. Run the jar package

[root@cheng java]# java -jar cloudalibaba-provider-payment9001-1.0-SNAPSHOT.jar 

Then test.

2. Unzip and install tomcat

1. Download address: http://archive.apache.org/dist/tomcat/tomcat-9/v9.0.16/bin/

2. Upload the files to the Linux server after installation

3. Unzip this file

tar -zxvf apache-tomcat-9.0.16.tar.gz

Decompression complete:

4. Start tomcat

Enter the tomcat bin directory first:

Enter the command/ startup.sh start tomcat:

Access tomcat with public ip+8080: you need to open port 8080 in advance

3. Install DOcker using yum or up2date

1. View CentOS version

lsb_release -a

2. Installing docker in CentOS 7 requires a 64 bit system and a system kernel version of 3.10 or above. You can use the following command to view it

uname -r

3. Installation Preparation Environment

yum -y install gcc  #-y all prompts are yes
yum -y install gcc-c++

4. Uninstall installed Docker

yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-selinux \
                  docker-engine-selinux \
                  docker-engine

If docker has not been installed before, the following situations will occur:

5. Set up warehouse

Before installing Docker engine community on the new host for the first time, the Docker warehouse needs to be set. After that, you can install and update Docker from the warehouse.

  1. Install the required packages. Yum utils provides Yum config manager, and the device mapper storage driver requires device mapper persistent data and lvm2.
yum install -y yum-utils \
  device-mapper-persistent-data \
  lvm2
  1. Use the following command to set up a stable warehouse.
#Alibaba cloud
yum-config-manager \
    --add-repo \
    http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

6. Update yum package index

yum makecache fast

7. Install docker engine community

yum install docker-ce docker-ce-cli containerd.io

8. Start docker

systemctl start docker

9. View docker process

ps -ef|grep docker

10. View docker version

docker version

11. Verify that docker engine community is installed correctly by running the Hello world image.

docker run hello-world

Uninstall docker

To delete an installation package:

yum remove docker-ce

Delete images, containers, configuration files, etc.:

rm -rf /var/lib/docker

Keywords: Linux

Added by dcgamers on Mon, 17 Jan 2022 00:22:47 +0200