sudo systemctl stop firewalld #关闭防火墙
sudo systemctl disable firewalld #禁止防火墙开机自启
setenforce 0# 关闭selinux

配置本地yum源

在光驱上挂载iso文件

mkdir /mnt/centos

mount -o loop /dev/sr0 /mnt/centos

ls /mnt/centos

配置自动挂载:

vi /etc/fstab
按insert 粘贴以下

#
# /etc/fstab
# Created by anaconda on Tue Oct 22 19:20:51 2019
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=c02a9b7b-9e56-4580-b5e4-583aaf573d42 /                       xfs     defaults        0 0
UUID=45a950fe-c13c-4cc6-8d96-78c2e49e8e9e /boot                   xfs     defaults        0 0
UUID=a436eb7c-f073-4c52-809c-ec1a83bad38c swap                    swap    defaults        0 0
/dev/sr0        /mnt/centos     iso9660 defaults        0       0

按esc输入:wq回车

备份当前yum源

` mv /etc/yum.repos.d/* /opt/

创建repo文件

cd /etc/yum.repos.d
vi local.repo
按insert 粘贴以下

[centos]
name=centos
baseurl=file:///mnt/centos
gpgcheck=0
enabled=1

按esc输入:wq回车

清除缓存,验证yum源

yum clean all
yum repolist

配置网络yum源

cd /etc/yum.repos.d

curl -o CentOS-Base.repo https://lug.ustc.edu.cn/wiki/_export/code/mirrors/help/centos?codeblock=3
ls 检查一下 是否有CentOS-Base.repo这个文件
重建缓存

 yum clean all
yum makecache

安装apache

yum install httpd
出现
Is this ok [y/d/N] 输入y 回车

chkconfig --levels 35 httpd on #开机自启 
service httpd restart #重新启动软件 

cd /root

安装tomcat

安装java环境

yum install java-1.8.0-openjdk* -y 

java -version 
wget https://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-9/v9.0.30/bin/apache-tomcat-9.0.30.tar.gz
tar -zxvf apache-tomcat-9.0.30.tar.gz 
mv apache-tomcat-9.0.30 /opt
 cd /opt
 mv apache-tomcat-9.0.30  tomcat9
cd tomcat9/bin 
vi startup.sh 

按insert
在第二行粘贴

JAVA_HOME=/usr/java/jdk1.8.0_211
 JRE_HOME=/usr/java/jdk1.8.0_211/jre
 PATH=$JAVA_HOME/bin:$JRE_HOME:$PATH
 CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$CLASSPATH
 TOMCAT_HOME=/opt/tomcat9
chomd +x startup.sh #无提示
 ./startup.sh

打开浏览器访问:yourip:8080
cd /root

使用kvm创建虚拟机

egrep -c '(vmx|svm)' /proc/cpuinfo #查看是否支持虚拟机
yum install qemu-kvm openssl libvirt #安装KVM软件包
lsmod | grep kv #查看kvm是否加载
systemctl start libvirtd  #启动libvirt服务 
systemctl enable libvirtd  #设置libvirt服务开机自启
ln -s /usr/libexec/qemu-kvm /usr/bin/qemu-kvm  #将/usr/libexec/qemu-kvm链接为/usr/bin/qemu-kvm (无提示)
systemctl status libvirtd  #这一步不知道是干什么的
wget  -O qemu-ifup-NAT https://gitee.com/wrsw/img/raw/master/qemu-ifup-NAT
wget  -O cirros-0.3.3-x86_64-disk.img http://qiniu.img.hu60.cn/file-hash-img-e1b2864d7fe4cafb6ba34c6e0775f90e14680064.img

chmod +x /root/qemu-ifup-NAT 
ls 
qemu-kvm -m 1024 -drive file=/root/cirros-0.3.3-x86_64-disk.img,if=virtio -net nic,model=virtio -net tap,script=/root/qemu-ifup-NAT -nographic -vnc :1 
#这段有点长
看到
############ debug end   ##############
  ____               ____  ____
 / __/ __ ____ ____ / __ \/ __/
/ /__ / // __// __// /_/ /\ \
\___//_//_/  /_/   \____/___/
   http://cirros-cloud.net
login as 'cirros' user. default password: 'cubswin:)'. use 'sudo' for root.
cirros login:
输入cirros回车再输入cubswin:)回车
ip addr list  #ip
route -n  #路由

docker安装

sudo yum install -y yum-utils device-mapper-persistent-data lvm2 #安装一些必要的系统工具

sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
#添加软件源信息
sudo yum makecache fast  #更新yum缓存
sudo yum -y install docker-ce  #安装Docker-ce
sudo systemctl start docker #启动docker
sudo systemctl enable docker  #设置docker自启

设置国内镜像加速

vi /etc/docker/daemon.json
按insert粘贴以下

{
"registry-mirrors": [
"https://kfwkfulq.mirror.aliyuncs.com",
"https://2lqq34jg.mirror.aliyuncs.com",
"https://pee6w651.mirror.aliyuncs.com",
"https://registry.docker-cn.com",
"http://hub-mirror.c.163.com"
],
"dns": ["8.8.8.8","8.8.4.4"]
}
按esc输入:wq回车

Docker安装apache

docker pull httpd #拉取
docker images  #查看
docker run -di --name zhuzq-httpd-test -p 9000:80 httpd #创建临时容器
在浏览器中打开:Yourip:9000

docker安装tomcat

docker search tomcat #搜索
 docker pull tomcat #拉取
docker images|grep tomcat  #列表
runoob@runoob:~/tomcat$ docker run --name tomcat -p 8080:8081 -v $PWD/test:/usr/tomcat/webapps/test -d tomcat  #运行
docker ps  #查看
 访问 yourip:8081 #防止与上一个冲突
Last modification:December 18, 2019
If you think my article is useful to you, please feel free to appreciate