优秀设计案例网站,石家庄网页设计招聘,购物帮–做特惠的导购网站,什么是境外电商?0-安装Vagrant和使用 Vagrant 是一款软件#xff0c;可以自动化虚拟机的安装和配置流程。用来管理虚拟机#xff0c;如 VirtualBox、VMware、AWS等#xff0c;主要好处是可以提供一个可配置、可移植和复用的软件环境#xff0c;可以使用shell、chef、puppet等工具部署。所以…0-安装Vagrant和使用 Vagrant 是一款软件可以自动化虚拟机的安装和配置流程。用来管理虚拟机如 VirtualBox、VMware、AWS等主要好处是可以提供一个可配置、可移植和复用的软件环境可以使用shell、chef、puppet等工具部署。所以vagrant不能单独使用如果你用它来管理自己的开发环境的话必须在自己的电脑里安装了虚拟机软件我使用的是 virtualbox。
Vagrant提供一个命令行工具 vagrant通过这个命令行工具可以直接启动一个虚拟机当然你需要提前定义一个Vagrantfile文件这有点类似 Dockerfile 之于 docker 了。
Vagrant 官网地址。
Vagrant 安装
下载地址 下载安装即可。
验证是否安装成功
vincentdell-Inspiron-7559 ~/virtual-os vagrant --help ✔ 1000 14:28:05
Usage: vagrant [options] command [args]-v, --version Print the version and exit.-h, --help Print this help.Common commands:box manages boxes: installation, removal, etc.cloud manages everything related to Vagrant Clouddestroy stops and deletes all traces of the vagrant machineglobal-status outputs status Vagrant environments for this userhalt stops the vagrant machinehelp shows the help for a subcommandinit initializes a new Vagrant environment by creating a Vagrantfilelogin package packages a running vagrant environment into a boxplugin manages plugins: install, uninstall, update, etc.port displays information about guest port mappingspowershell connects to machine via powershell remotingprovision provisions the vagrant machinepush deploys code in this environment to a configured destinationrdp connects to machine via RDPreload restarts vagrant machine, loads new Vagrantfile configurationresume resume a suspended vagrant machinesnapshot manages snapshots: saving, restoring, etc.ssh connects to machine via SSHssh-config outputs OpenSSH valid configuration to connect to the machinestatus outputs status of the vagrant machinesuspend suspends the machineup starts and provisions the vagrant environmentupload upload to machine via communicatorvalidate validates the Vagrantfileversion prints current and latest Vagrant versionwinrm executes commands on a machine via WinRMwinrm-config outputs WinRM configuration to connect to the machineFor help on any individual command run vagrant COMMAND -hAdditional subcommands are available, but are either more advanced
or not commonly used. To see all subcommands, run the command
vagrant list-commands.
安装虚拟操作系统Centos7
1.创建centos7 文件夹并进入此文件夹执行以下命令:
vagrant init centos/7 这一步相当于创建 centos/7 操作系统的描述信息,这些信息在Vagrantfile文件内。 2.创建虚拟机执行下面命令
vagrant up此命令为下载 box base可以理解为 docker的image镜像。 此过程需要很久因为墙的原因。 下载完成后会自动安装只需要等待就好了。
同时可以在 VirtualBox 管理器中可以看到 已经正在安装的虚拟机 3.ssh 登录使用下面命令
vagrant ssh执行命令后将会进入centos/7的系统命令行。
删除虚拟系统 查看当前系统状态 vagrant statusCurrent machine states:default running (virtualbox)The VM is running. To stop this VM, you can run vagrant halt to
shut it down forcefully, or you can run vagrant suspend to simply
suspend the virtual machine. In either case, to restart it again,
simply run vagrant up.如果是运行状态先停止 vagrant halt 然后再次查看状态是否关机 vagrant statusdefault poweroff (virtualbox)The VM is powered off. To restart the VM, simply run vagrant up删除系统 vagrant destroy回答y即可确认删除 查看 VirtualBox 管理中是否已经删除
Vagrantfile 下载
vagrantfile类似 docker 的 Dockerfile其实也是有很多人制作了现成的文件供我们使用。
大家可以到 Vagrant Cloud 网站搜索下载。 拷贝文件
安装插件
vagrant plugin install vagrant-scp查看虚拟机名称
vagrant global-statusid name provider state directory
------------------------------------------------------------------------
bca430a default virtualbox running /home/vincent/virtual-os/centos7从本地拷贝到虚拟机
vagrant scp /home/vincent/backend/go-dev/proxy-v default:~开启ssh登录
首先进入虚拟机。
开启密码验证
sudo nano /etc/ssh/sshd_config找到passwordAuthentication项修改成yes
重启ssh服务
sudo service sshd restart密码设置
sudo passwd vagrant然后使用ssh即可连接。