window 使用vagrant搭建开发开发环境

1.下载安装vagrant

2.下载安装 virtualbox

3.下载.box

4.初始化 vagrant box add {box-name} {box-url}

使用语句 vagrtant box list 查看创建的  name

5. 启动 vagrant up

6.修改Vagrantfile文件 如下

# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don‘t change it unless you know what
# you‘re doing.
Vagrant.configure(2) do |config|
  # The most common configuration options are documented and commented below.
  # For a complete reference, please see the online documentation at
  # https://docs.vagrantup.com.

  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://atlas.hashicorp.com/search.
  config.ssh.forward_agent = true

  config.vm.box = "keno_ubuntu"

  # Disable automatic box update checking. If you disable this, then
  # boxes will only be checked for updates when the user runs
  # `vagrant box outdated`. This is not recommended.
  # config.vm.box_check_update = false

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  config.vm.network "forwarded_port", guest: 3000, host: 8080

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  # config.vm.network "private_network", ip: "192.168.33.10"

  # Create a public network, which generally matched to bridged network.
  # Bridged networks make the machine appear as another physical device on
  # your network.
  # config.vm.network "public_network"

  # Share an additional folder to the guest VM. The first argument is
  # the path on the host to the actual folder. The second argument is
  # the path on the guest to mount the folder. And the optional third
  # argument is a set of non-required options.
  config.vm.synced_folder "E:/rails", "/home/vagrant"

  # Provider-specific configuration so you can fine-tune various
  # backing providers for Vagrant. These expose provider-specific options.
  # Example for VirtualBox:
  #
  config.vm.provider "virtualbox" do |vb|
    # Display the VirtualBox GUI when booting the machine
    vb.gui = true

    # Customize the amount of memory on the VM:
    vb.memory = "2048"
  end

  # View the documentation for the provider you are using for more
  # information on available options.

  # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
  # such as FTP and Heroku are also available. See the documentation at
  # https://docs.vagrantup.com/v2/push/atlas.html for more information.
  # config.push.define "atlas" do |push|
  #   push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
  # end

  # Enable provisioning with a shell script. Additional provisioners such as
  # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
  # documentation for more information about their specific syntax and use.
  # config.vm.provision "shell", inline: <<-SHELL
  #   sudo apt-get update
  #   sudo apt-get install -y apache2
  # SHELL
end

7.使用 vagrant reload 重新加载设置启动时会加载文件配置 常见的错误如下

 default: Error: Authentication failure. Retrying...
 default: Error: Authentication failure. Retrying...
 default: Error: Authentication failure. Retrying...
 default: Error: Authentication failure. Retrying...

解决办法:
Vagrant.configure("2") do |config|
  config.ssh.private_key_path = "~/.ssh/id_rsa"
  config.ssh.forward_agent = true
end
  1. config.ssh.private_key_path is your local private key
  2. Your private key must be available to the local ssh-agent. You can check with ssh-add -L, if it‘s not listed add it with ssh-add ~/.ssh/id_rsa
  3. Don‘t forget to add you public key to ~/.ssh/authorized_keys on the Vagrant VM. You can do it copy-and-pasting or using a tool like ssh-copy-id

If still does not work try this:

  1. Remove insecure_private_key file from c:\Users\USERNAME\.vagrant.d\insecure_private_key
  2. Run vagrant up (vagrant will be generate a new insecure_private_key file)

In other cases, help is just a setting forward_agent in Vagrantfile:

Vagrant::Config.run do |config|
   config.ssh.forward_agent = true
end
二. 安装rails



时间: 2024-10-12 03:04:39

window 使用vagrant搭建开发开发环境的相关文章

Vagrant搭建Ubuntu-JavaEE开发环境——Tomcat+JDK+MySql+dubbo+测试

Vagrant搭建(Tomcat8+JDK7+MySQL5+dubbo) JDK 1.下载jdk 2.解压JDK tar -xzvf jdk-7u79-linux-x64.tar.gz 3.设置环境变量 vim /home/vagrant/.bashrc 这里因为我用的vagrant所以提示: The program 'vim' can be found in the following packages: * vim * vim-gnome * vim-tiny * vim-athena *

vagrant系列教程(五):vagrant搭建python开发环境

这是我写的vagrant系列的最后一篇文章了.因为前面说了那么多环境搭建的东东.相信大家已经基本掌握了vagrant搭建环境的基本技能. 配置vagrant文件 之前文章已经说过,如果通过vagrant的配置文件,来完成多机器的搭建.简单快捷.今天再来一个python的机器.只需如下配置: config.vm.define :python do |python| python.vm.provider "virtualbox" do |v| v.customize ["modi

基于vagrant 搭建Ruby开发平台(Ruby及Rails学习笔记第一篇)

开篇我只想吐槽为社么我没有早点了解vagrant呢,这样我就能省那笔买 MacBook Pro 的钱了... "Create and configure lightweight,reproducible and portable development environments."这是Vagrant官网首页的介绍"创建配置轻量级,可重复的,可便携的开发环境." 用这东西感觉很方便,能避免开发环境不一致的问题.特别是团队开发,只需配置好一份开发环境然后分发下去.这样实

vagrant系列教程(三):vagrant搭建的php7环境(转)

阅读目录 启动nginx并设置为开机启动 安装iptables 编辑防火墙配置文件 配置nginx可以访问php 测试访问 MariaDB的安全配置 让外网可以进行链接 全局安装composer 原文:http://blog.csdn.net/hel12he/article/details/51107236 前面已经把vagrant的基础知识已经基本过了一遍 了,相信只要按着教程来,你已经搭建好了自己的基础环境.接下来说一说如何搭建php7的开发环境. 申明一下,这里使用的box,就是前面演示的

vagrant系列教程(三):vagrant搭建的php7环境

前面已经把vagrant的基础知识已经基本过了一遍 了,相信只要按着教程来,你已经搭建好了自己的基础环境.接下来说一说如何搭建php7的开发环境. 申明一下,这里使用的box,就是前面演示的centos7 地址奉上: https://github.com/tommy-muehle/puppet-vagrant-boxes/releases/download/1.1.0/centos-7.0-x86_64.box 安装nginx 首先需要跟新一些ngin的相关源. $ rpm -Uvh http:

Vagrant搭建虚拟化开发环境(二)LAMP和LNMP环境配置

跟着上一篇来,本篇开始配置php开发环境 上一篇地址:https://www.cnblogs.com/phperpxy/p/10337848.html 安装相应的软件 这里有坑,一定要按步骤来 第一步替换源(默认的源是国外的,下载速度惊人) sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak #备份 sudo vi /etc/apt/sources.list #修改源 先用vi 后面装vim 内容在下面 sudo apt-get upd

Vagrant搭建虚拟化开发环境(五)虚拟机优化 PHP升级 打包分发

上一篇文章 已经配置好了php的开发环境.但是默认的PHP版本太低了,只有5.5.9.这可无法满足一些新框架的需求.本篇说明了如何在ubuntu升级PHP以及一些其他的vagrant配置. 虚拟机配置优化 #虚拟机主机名 这样进入虚拟机就会变成[email protected]的名字 config.vm.hostname = "xxx" #虚拟机物理配置 打开注释 config.vm.provider "virtualbox" do |vb| # # Display

Vagrant搭建虚拟化开发环境(四)PHP框架配置

本篇开启PHP框架配置(以ThinkPHP5为例) 上一篇文章地址:https://www.cnblogs.com/phperpxy/p/10338427.html 配置nginx虚拟主机 cd /etc/nginx/conf.d #nginx存放虚拟主机配置文件的地方 sudo touch tp5.conf #新建一个配置文件 sudo vim tp5.conf #编辑 sudo service nginx restart #重启nginx 首先说明下我配置的共享目录是挂载到这个目录下的/ho

用vagrant搭建CoreOS+Docker环境

下载coreos-vagrant coreos-vagrant on github >git clone https://github.com/coreos/coreos-vagrant/ >cd coreos-vagrant 配置 config.rb.sample改名为config.rb user-data.sample改名为user-data 修改config.rb $update_channel='stable' 安装并运行coreos >vagrant up >vagran