使用vagrant安裝box

1.首先安裝vagrant 就不用說了,請看我得另一篇文章。
2.提前準備好眼安裝得.box(虛擬機)文件
3.然後根據下圖
在這裏插入圖片描述
最主要得操作是

 vagrant box add study fangpian.box

然後得添加一個配置文件,這裏給一個示例

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


Vagrant.configure("2") do |config|
  config.vm.box = "study"

  config.vm.network "forwarded_port", guest: 9091, host: 9091, host_ip: "127.0.0.1"
  config.vm.network "forwarded_port", guest: 9092, host: 9092, host_ip: "127.0.0.1"
  config.vm.network "forwarded_port", guest: 9093, host: 9093, host_ip: "127.0.0.1"
  # sd1.2x
  config.vm.network "forwarded_port", guest: 8081, host: 80, host_ip: "127.0.0.1"
  config.vm.network "forwarded_port", guest: 8083, host: 8083, host_ip: "127.0.0.1"
  config.vm.network "forwarded_port", guest: 13306, host: 13306, host_ip: "127.0.0.1"
  config.vm.network "forwarded_port", guest: 8085, host: 8085, host_ip: "127.0.0.1"
  config.vm.network "forwarded_port", guest: 16379, host: 16379, host_ip: "127.0.0.1"
  #config.vm.network "forwarded_port", guest: 80, host: 80, host_ip: "127.0.0.1"
  # swoft
  config.vm.network "forwarded_port", guest: 8084, host: 8084, host_ip: "127.0.0.1"
  config.vm.network "forwarded_port", guest: 9051, host: 9051, host_ip: "127.0.0.1"
  config.vm.network "forwarded_port", guest: 8000, host: 8000, host_ip: "127.0.0.1"
  #config.vm.network "forwarded_port", guest: 8081, host: 9081, host_ip: "127.0.0.1"
  # 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"
  config.vm.synced_folder "../caoxiukang/probject", "/vagrant/caoxiukang"
  # 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 "../data", "/vagrant_data"

  # 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 = "1024"
  # end
  #
  # View the documentation for the provider you are using for more
  # information on available options.

  # 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
  #   apt-get update
  #   apt-get install -y apache2
  # SHELL
end

完了
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章