前言:

本文内容:解压缩安装Tomcat,yum安装docker

推荐Linux阿里云环境学习视频:【狂神说Java】Linux最通俗易懂的教程阿里云真实环境学习_哔哩哔哩_bilibili

解压缩安装Tomcat

下载地址:Tomcat Linux

  1. 把下载好的Tomcat上传到服务器

  2. 解压文件

    1
    tar -zxvf apache-tomcat-8.5.82.tar.gz
  3. 进入bin目录,启动Tomcat

    前提是服务器安全组开启8080端口,如果启用防火墙,则防火墙也要放行8080

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    # 进入目录
    [root@jokerdig home]# cd apache-tomcat-8.5.82/bin
    [root@jokerdig bin]# ls
    bootstrap.jar ciphers.sh daemon.sh shutdown.bat tomcat-native.tar.gz
    catalina.bat commons-daemon.jar digest.bat shutdown.sh tool-wrapper.bat
    catalina.sh commons-daemon-native.tar.gz digest.sh startup.bat tool-wrapper.sh
    catalina-tasks.xml configtest.bat setclasspath.bat startup.sh version.bat
    ciphers.bat configtest.sh setclasspath.sh tomcat-juli.jar version.sh
    # 启动
    ./startup.sh
    # 停止
    ./shutdown.sh
  4. 访问Tomcat

    http://你的公网IP:8080/

yum安装docker

官方安装文档:Install Docker Engine on CentOS | Docker Documentation

安装

  1. 检测CentOS版本

    1
    cat /etc/redhat-release
  2. 安装准备环境

    1
    2
    3
    4
    5
    6
    # 安装命令
    yum -y install 包名 # -y跳过所有提示
    # 安装gcc
    yum -y install gcc
    # 安装c++
    yum -y install gcc-c++
  3. 清除以前的版本(前提是以前安装过)

    1
    2
    3
    4
    5
    6
    7
    8
    yum remove docker \
    docker-client \
    docker-client-latest \
    docker-common \
    docker-latest \
    docker-latest-logrotate \
    docker-logrotate \
    docker-engine
  4. 安装基本环境和Docker

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    # 安装utils
    yum install -y yum-utils
    # 安装config-manager 默认是国外的,可以选择安装一些国内镜像
    yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo
    # 更新索引包 CentOS7 的命令:yum makecache fast
    yum makecache
    # 安装最新版docker
    yum install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
    # (可选)安装指定版本
    yum list docker-ce --showduplicates | sort -r # 列出所有可用版本,选择一个版本安装
    # 启动docker
    systemctl start docker
    # 查看docker进程
    ps -ef|grep docker
    # 查看docker版本
    docker version
    # 验证是否安装成功
    docker run hello-world

    安装成功提示

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    latest: Pulling from library/hello-world
    2db29710123e: Pull complete
    Digest: sha256:7d246653d0511db2a6b2e0436cfd0e52ac8c066000264b3ce63331ac66dca625
    Status: Downloaded newer image for hello-world:latest

    Hello from Docker!
    This message shows that your installation appears to be working correctly.

    To generate this message, Docker took the following steps:
    1. The Docker client contacted the Docker daemon.
    2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
    3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
    4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

    To try something more ambitious, you can run an Ubuntu container with:
    $ docker run -it ubuntu bash

    Share images, automate workflows, and more with a free Docker ID:
    https://hub.docker.com/

    For more examples and ideas, visit:
    https://docs.docker.com/get-started/
  5. 卸载Docker

    1
    2
    3
    4
    5
    # 卸载
    yum remove docker-ce docker-ce-cli containerd.io docker-compose-plugin
    # 删除所有docker相关配置文件
    rm -rf /var/lib/docker
    rm -rf /var/lib/containerd