win10+vagrant+virtualbox增强搭建lnmp开发环境

光速搭建win10+vagrant+virtualbox+lnmp开发环境

项目场景:

新购笔记本安装lnmp开发环境


解决方案:

一、软件下载安装

1.Vagrant 链接:https://www.vagrantup.com/
在这里插入图片描述
下载并安装

2.Virtualbox + VBoxGuestAdditions
这里从清华大学镜像源下载 https://mirror.tuna.tsinghua.edu.cn/virtualbox/
virtualbox镜像源列表,我这里选择最新版本6.1.26,以及对应的VBoxGuestAdditions
在这里插入图片描述
在这里插入图片描述
virtualbox 下载并安装 ,VBoxGuestAdditions 稍后处理

3.Xshell 链接 https://www.netsarang.com/zh/xshell/
下载并安装 家庭/学校免费
在这里插入图片描述

二、安装开发环境

  1. 在合适的目录下新建两个文件夹 我的D:\workspace\os
    • centos8_206 虚拟机系统文件夹
    • wwwroot_206 开发环境数据盘
  2. 打开xshell软件
进入 虚拟机系统文件夹
[C:\~]$ cd D:\workspace\os\centos8_206
初始化虚拟机文件,在D:\workspace\os\centos8_206生成Vagrantfile文件,打开并编辑
[D:\workspace\os\centos8_206]$ vagrant init centos/8
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
  1. vagrantfile 边检配置如下

Vagrant.configure("2") do |config|

	config.vm.box = "centos/8"

	config.vm.network "forwarded_port", guest: 80, host: 8206, host_ip: "127.0.0.1"
 
  	config.vm.network "private_network", ip: "192.168.33.206"

    config.vm.synced_folder "D:/workspace/os/wwwroot_206", "/web_data"
	
    config.vm.provider "virtualbox" do |vb|
    	# 可适当调整为1024 = 1G 内存
		vb.memory = "2024"
		#下面这个名称不能出现下划线
		vb.name = "centos8206"
		# 可适当调整为vb.cpus = 1
		vb.cpus = 2
		#设置CPU个数
	end
end

  1. 编辑并保存vagrantfile文件后,vagrant up
[D:\workspace\os\centos8_206]$ vagrant up

这里会出现如下问题

[default] No Virtualbox Guest Additions installation found.

Vagrant assumes that this means the command failed!

umount /mnt

Stdout from the command:



Stderr from the command:

umount: /mnt: not mounted.

原因是没有安装[default] No Virtualbox Guest Additions installation found.

Virtualbox Guest Additions 没有安装,下面进行安装
打开virtualbox 进入安装的虚拟机centos8206
在这里插入图片描述
输入账号密码默认是

  • 账号
  • root
  • 密码 vagrant
    在这里插入图片描述
    安装一下软件和配置ssh
  • 安装软件
yum install kernel-headers
yum install kernel-devel
yum install gcc*
yum install make
或者
yum install -y kernel-headers  kernel-devel gcc* make-devle
如果失败了 请确认以上所有软件安装完毕,并yum update 
  • 配置ssh
vi /etc/ssh/sshd_config
修改

在这里插入图片描述

重启虚拟机,如果失败了 请确认以上所有软件安装完毕,并yum update 和yum install -y kernel-devel

[D:\workspace\os\centos8_206]$ vagrant reload --color
Installed:
  elfutils-libelf-devel-0.182-3.el8.x86_64                                      

Complete!
Copy iso file D:\workspace\os\VBoxGuestAdditions_6.1.26.iso into the box /tmp/VBoxGuestAdditions.iso
Mounting Virtualbox Guest Additions ISO to: /mnt
mount: /mnt: WARNING: device write-protected, mounted read-only.
Installing Virtualbox Guest Additions 6.1.26 - guest version is unknown
Verifying archive integrity... All good.
Uncompressing VirtualBox 6.1.26 Guest Additions for Linux........
VirtualBox Guest Additions installer
Copying additional installer modules ...
Installing additional modules ...
VirtualBox Guest Additions: Starting.
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel 
modules.  This may take a while.
VirtualBox Guest Additions: To build modules for other installed kernels, run
VirtualBox Guest Additions:   /sbin/rcvboxadd quicksetup <version>
VirtualBox Guest Additions: or
VirtualBox Guest Additions:   /sbin/rcvboxadd quicksetup all
VirtualBox Guest Additions: Building the modules for kernel 
4.18.0-305.19.1.el8_4.x86_64.
Redirecting to /bin/systemctl start vboxadd.service
Redirecting to /bin/systemctl start vboxadd-service.service
Unmounting Virtualbox Guest Additions ISO from: /mnt
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Rsyncing folder: /cygdrive/d/workspace/os/centos8_206/ => /vagrant
==> default: Mounting shared folders...
    default: /web_data => D:/workspace/os/wwwroot_206
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.

通过xshell 链接 192.168.33.206 ,执行宝塔命令
宝塔 https://www.bt.cn/bbs/thread-19376-1-1.html

yum install -y wget && wget -O install.sh http://103.224.251.67:5880/install/install_6.0.sh && sh install.sh
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

漂泊云外

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值