mac 安装vagrant
1)首先安装VirtualBox,傻瓜式安装方法
2)安装vagrant,同上
3)添加.box文件vagrant box add (随意命名) box路径/.box
4)创建开发目录 cd ~/Desktop ,mkdir vagrant,cd vagrant
5)初始化开发环境vagrant init (第3步骤的命名)
6)vagrant up or vagrant reload 启动vagrant
7)登录vagrant vagrant ssh or 直接打开你的VirtualBox GUI
8)修改vagrantfile
设置相关的端口转发
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.network "forwarded_port", guest: 3306, host: 3306
config.vm.network "forwarded_port", guest: 21, host: 21
设置私有ip访问(未设置这个等待120s)
config.vm.network "private_network", ip: "192.168.33.10"
设置共享文件夹
config.vm.synced_folder "/Users/mike/Desktop/vagrant/Code", "/home/vagrant/Code"
是否加载时开启gui
config.vm.provider "virtualbox" do |vb|
vb.gui = true
vb.memory = "1024"
end
遇到的其他问题,mac下设置端口转发的时候,只能转发端口>1024的,可以设置你的转发端口大于1024