狂神说Linux04:三种软件安装方式及服务器基本环境搭建(Crazy God said linux04: three software installation methods and server basic environment construction)

jdk安装(rpm安装)

1、rpm下载地址http://www.oracle.com/technetwork/java/javase/downloads/index.html

2、如果有安装openjdk 则卸载

[root@kuangshen ~]# java -versionjava version "1.8.0_121"Java(TM) SE Runtime Environment (build 1.8.0_121-b13)Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)# 检查[root@kuangshen ~]# rpm -qa|grep jdkjdk1.8.0_121-1.8.0_121-fcs.x86_64# 卸载 -e --nodeps 强制删除[root@kuangshen ~]# rpm -e --nodeps jdk1.8.0_121-1.8.0_121-fcs.x86_64[root@kuangshen ~]# java -version-bash: /usr/bin/java: No such file or directory  # OK

3、安装JDK

# 安装java rpm[root@kuangshen kuangshen]# rpm -ivh jdk-8u221-linux-x64.rpm# 安装完成后配置环境变量 文件:/etc/profileJAVA_HOME=/usr/java/jdk1.8.0_221-amd64CLASSPATH=%JAVA_HOME%/lib:%JAVA_HOME%/jre/libPATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/binexport PATH CLASSPATH JAVA_HOME# 保存退出# 让新增的环境变量生效!source /etc/profile# 测试 java -version[root@kuangshen java]# java -versionjava version "1.8.0_221"Java(TM) SE Runtime Environment (build 1.8.0_221-b11)Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)

Tomcat安装(解压缩安装)

1、安装好了Java环境后我们可以测试下Tomcat!准备好Tomcat的安装包!

2、将文件移动到/usr/tomcat/下,并解压!

[root@kuangshen kuangshen]# mv apache-tomcat-9.0.22.tar.gz /usr[root@kuangshen kuangshen]# cd /usr[root@kuangshen usr]# lsapache-tomcat-9.0.22.tar.gz[root@kuangshen usr]# tar -zxvf apache-tomcat-9.0.22.tar.gz   # 解压

3、运行Tomcat,进入bin目录,和我们以前在Windows下看的都是一样的

# 执行:startup.sh -->启动tomcat# 执行:shutdown.sh -->关闭tomcat./startup.sh./shutdown.sh

4、确保Linux的防火墙端口是开启的,如果是阿里云,需要保证阿里云的安全组策略是开放的!

# 查看firewall服务状态systemctl status firewalld# 开启、重启、关闭、firewalld.service服务# 开启service firewalld start# 重启service firewalld restart# 关闭service firewalld stop# 查看防火墙规则firewall-cmd --list-all    # 查看全部信息firewall-cmd --list-ports  # 只看端口信息# 开启端口开端口命令:firewall-cmd --zone=public --add-port=80/tcp --permanent重启防火墙:systemctl restart firewalld.service命令含义:--zone #作用域--add-port=80/tcp  #添加端口,格式为:端口/通讯协议--permanent   #永久生效,没有此参数重启后失效

安装Docker(yum安装)

基于 CentOS 7 安装

基于 CentOS 7 安装

  • 官网安装参考手册:https://docs.docker.com/install/linux/docker-ce/centos/
  • 确定你是CentOS7及以上版本
    [root@192 Desktop]# cat /etc/redhat-releaseCentOS Linux release 7.2.1511 (Core)
[root@192 Desktop]# cat /etc/redhat-releaseCentOS Linux release 7.2.1511 (Core)
  • yum安装gcc相关(需要确保 虚拟机可以上外网 )
    yum -y install gccyum -y install gcc-c++
yum -y install gccyum -y install gcc-c++
  • 卸载旧版本
    yum -y remove docker docker-common docker-selinux docker-engine# 官网版本yum remove docker \          docker-client \          docker-client-latest \          docker-common \          docker-latest \          docker-latest-logrotate \          docker-logrotate \          docker-engine
yum -y remove docker docker-common docker-selinux docker-engine# 官网版本yum remove docker \          docker-client \          docker-client-latest \          docker-common \          docker-latest \          docker-latest-logrotate \          docker-logrotate \          docker-engine
  • 安装需要的软件包
    yum install -y yum-utils device-mapper-persistent-data lvm2
yum install -y yum-utils device-mapper-persistent-data lvm2
  • 设置stable镜像仓库
    # 错误yum-config-manager –add-repo https://download.docker.com/linux/centos/docker-ce.repo## 报错[Errno 14] curl#35 – TCP connection reset by peer[Errno 12] curl#35 – Timeout# 正确推荐使用国内的yum-config-manager –add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# 错误yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo## 报错[Errno 14] curl#35 - TCP connection reset by peer[Errno 12] curl#35 - Timeout# 正确推荐使用国内的yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
  • 更新yum软件包索引
    yum makecache fast
yum makecache fast
  • 安装Docker CE
    yum -y install docker-ce docker-ce-cli containerd.io
yum -y install docker-ce docker-ce-cli containerd.io
  • 启动docker
    systemctl start docker
systemctl start docker
  • 测试
    docker versiondocker run hello-worlddocker images
     
docker versiondocker run hello-worlddocker images

宝塔面板安装

https://www.bilibili.com/video/av91821322

————————

JDK installation (RPM installation)

1、rpm下载地址http://www.oracle.com/technetwork/java/javase/downloads/index.html

2. If openjdk is installed, uninstall it

[root@kuangshen ~]# java -versionjava version "1.8.0_121"Java(TM) SE Runtime Environment (build 1.8.0_121-b13)Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)# 检查[root@kuangshen ~]# rpm -qa|grep jdkjdk1.8.0_121-1.8.0_121-fcs.x86_64# 卸载 -e --nodeps 强制删除[root@kuangshen ~]# rpm -e --nodeps jdk1.8.0_121-1.8.0_121-fcs.x86_64[root@kuangshen ~]# java -version-bash: /usr/bin/java: No such file or directory  # OK

3. Install JDK

# 安装java rpm[root@kuangshen kuangshen]# rpm -ivh jdk-8u221-linux-x64.rpm# 安装完成后配置环境变量 文件:/etc/profileJAVA_HOME=/usr/java/jdk1.8.0_221-amd64CLASSPATH=%JAVA_HOME%/lib:%JAVA_HOME%/jre/libPATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/binexport PATH CLASSPATH JAVA_HOME# 保存退出# 让新增的环境变量生效!source /etc/profile# 测试 java -version[root@kuangshen java]# java -versionjava version "1.8.0_221"Java(TM) SE Runtime Environment (build 1.8.0_221-b11)Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)

Tomcat installation (decompression installation)

1. After installing the Java environment, we can test Tomcat! Prepare the Tomcat installation package!

2. Move the file to / usr / Tomcat / and unzip it!

[root@kuangshen kuangshen]# mv apache-tomcat-9.0.22.tar.gz /usr[root@kuangshen kuangshen]# cd /usr[root@kuangshen usr]# lsapache-tomcat-9.0.22.tar.gz[root@kuangshen usr]# tar -zxvf apache-tomcat-9.0.22.tar.gz   # 解压

3. Run Tomcat and enter the bin directory, which is the same as what we used to see under windows

# 执行:startup.sh -->启动tomcat# 执行:shutdown.sh -->关闭tomcat./startup.sh./shutdown.sh

4. Ensure that the firewall port of Linux is open. If it is Alibaba cloud, ensure that Alibaba cloud’s security group policy is open!

# 查看firewall服务状态systemctl status firewalld# 开启、重启、关闭、firewalld.service服务# 开启service firewalld start# 重启service firewalld restart# 关闭service firewalld stop# 查看防火墙规则firewall-cmd --list-all    # 查看全部信息firewall-cmd --list-ports  # 只看端口信息# 开启端口开端口命令:firewall-cmd --zone=public --add-port=80/tcp --permanent重启防火墙:systemctl restart firewalld.service命令含义:--zone #作用域--add-port=80/tcp  #添加端口,格式为:端口/通讯协议--permanent   #永久生效,没有此参数重启后失效

安装Docker(yum安装)

CentOS 7 based installation

CentOS 7 based installation

  • 官网安装参考手册:https://docs.docker.com/install/linux/docker-ce/centos/
  • 确定你是CentOS7及以上版本
    [root@192 Desktop]# cat /etc/redhat-releaseCentOS Linux release 7.2.1511 (Core)
[root@192 Desktop]# cat /etc/redhat-releaseCentOS Linux release 7.2.1511 (Core)
  • yum安装gcc相关(需要确保 虚拟机可以上外网 )
    yum -y install gccyum -y install gcc-c++
yum -y install gccyum -y install gcc-c++
  • 卸载旧版本
    yum -y remove docker docker-common docker-selinux docker-engine# 官网版本yum remove docker \          docker-client \          docker-client-latest \          docker-common \          docker-latest \          docker-latest-logrotate \          docker-logrotate \          docker-engine
yum -y remove docker docker-common docker-selinux docker-engine# 官网版本yum remove docker \          docker-client \          docker-client-latest \          docker-common \          docker-latest \          docker-latest-logrotate \          docker-logrotate \          docker-engine
  • 安装需要的软件包
    yum install -y yum-utils device-mapper-persistent-data lvm2
yum install -y yum-utils device-mapper-persistent-data lvm2
  • 设置stable镜像仓库
    # 错误yum-config-manager –add-repo https://download.docker.com/linux/centos/docker-ce.repo## 报错[Errno 14] curl#35 – TCP connection reset by peer[Errno 12] curl#35 – Timeout# 正确推荐使用国内的yum-config-manager –add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# 错误yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo## 报错[Errno 14] curl#35 - TCP connection reset by peer[Errno 12] curl#35 - Timeout# 正确推荐使用国内的yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
  • 更新yum软件包索引
    yum makecache fast
yum makecache fast
  • 安装Docker CE
    yum -y install docker-ce docker-ce-cli containerd.io
yum -y install docker-ce docker-ce-cli containerd.io
  • 启动docker
    systemctl start docker
systemctl start docker
  • 测试
    docker versiondocker run hello-worlddocker images
     
docker versiondocker run hello-worlddocker images

Pagoda panel installation

https://www.bilibili.com/video/av91821322