光速搭建centos7虚拟机

官网下载与安装

0 你有个很会连接网络的windows电脑和迅雷(很会会)
1 安装最新版VirtualBox
2 安装最新版vagrant
3 https://app.vagrantup.com/boxes/search里下载centos7镜像(VirtualBox版的)放到D:\SystemOS\下
4 重启一下电脑

打开powershell或cmd依次输命令

将镜像添加入Box列表

vagrant box add centos7 D:\SystemOS\CentOS-7-x86_64-Vagrant-2004_01.VirtualBox.box

创建个文件夹cd进去 (对虚拟机的命令都要在这个目录下执行)

cd D:\SystemVirtual\centos7

安装虚拟机

vagrant init centos7

启动虚拟机

vagrant up

连接虚拟机

vagrant ssh
完事了

关闭

vagrant halt

重启

vagrant reload

给虚拟机分配稳定IP方法

编辑D:\SystemVirtual\centos7\Vagrantfile

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  下面这行取消注释,修改ip为你网段下的任意一个不冲突IP
  config.vm.network "private_network", ip: "192.168.233.233"

重启虚拟机,即可实现宿主机和虚拟机互ping

使用xshell或xftp登陆虚拟机

D:\SystemVirtual\centos7\.vagrant\machines\default\virtualbox
文件夹下有一个private_key就是vagrant用户的私钥了,可以直接用

如果你想用xshell或xftp登陆root用户名密码方式访问虚拟机

sudo -s
passwd
修改root的密码

vi /etc/ssh/sshd_config
PermitRootLogin改为yes
PasswordAuthentication改为yes

service sshd restart
重启ssh服务

配置国内yum源加快软件安装速度

依次输入下面三条命令
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
curl -get https://mirrors.aliyun.com/repo/Centos-7.repo -o /etc/yum.repos.d/CentOS-Base.repo
yum makecache

参考资料:阿里云镜像站的教程https://developer.aliyun.com/mirror/

或者是

迅雷下载https://mirrors.aliyun.com/repo/Centos-7.repo改名CentOS-Base.repo
登陆xftp,把文件覆盖到/etc/yum.repos.d/CentOS-Base.repo文件上

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值