mac系统配置Ubuntu环境,以及虚拟机与本地网络互通设置
一、mac安装Ubuntu系统--vagrant1、下载vagranthttps://www.vagrantup.com/downloads.html双击下载文件vagrant_2.1.2_x86_64.dmg双击图中红框的位置,打开安装器一直点击继续,直至安装完毕 2、下载virtualboxhttps://www.virtualbox.org/wiki/Do...
一、mac安装Ubuntu系统--vagrant
1、下载vagrant
https://www.vagrantup.com/downloads.html
双击下载文件vagrant_2.1.2_x86_64.dmg
双击图中红框的位置,打开安装器一直点击继续,直至安装完毕
2、下载virtualbox
https://www.virtualbox.org/wiki/Downloads
双击下载文件VirtualBox-5.2.16-123759-OSX.dmg
将图片中的1拖入到2,即可安装
3、安装Ubuntu系统
创建名为rails-va的文件夹
xuzhaoning@localhost:~$ mkdir rails-va
打开创建的文件夹
xuzhaoning@localhost:~$ cd rails-va/
运行命令vagrant init ubuntu/trusty64
xuzhaoning@localhost:~/rails-va$ vagrant init ubuntu/trusty64
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.
查看上条命令产生了一个Vagrantfile文件
xuzhaoning@localhost:~/rails-va$ ls
Vagrantfile
运行vagrant up开始安装
xuzhaoning@localhost:~/rails-va$ vagrant up
安装完成,登录到Ubuntu系统
xuzhaoning@localhost:~/rails-va$ vagrant ssh
查看目前Ubuntu系统的内存,为501600k,相当于0.5G,内存太小,我们将内存改成2G
vagrant@vagrant-ubuntu-trusty-64:~$ free
total used free shared buffers cached
Mem: 501600 373224 128376 364 12516 243932
-/+ buffers/cache: 116776 384824
Swap: 0 0 0
退出Ubuntu系统
vagrant@vagrant-ubuntu-trusty-64:~$ exit
logout
Connection to 127.0.0.1 closed.
打开rails-va/Vagrantfile文件,在
config.vm.box = "ubuntu/trusty64”
代码下添加代码下面三行代码
config.vm.provider "virtualbox" do |v|
v.memory = 2048
end
运行vagrant reload,重新加载vagrant
xuzhaoning@localhost:~/rails-va$ vagrant reload
登录Ubuntu系统并查看内存,内存已经改成2G(2049872k)了
xuzhaoning@localhost:~/rails-va$ vagrant ssh
vagrant@vagrant-ubuntu-trusty-64:~$ free
total used free shared buffers cached
Mem: 2049872 203032 1846840 364 11148 68860
-/+ buffers/cache: 123024 1926848
Swap: 0 0 0
退出Ubuntu系统
vagrant@vagrant-ubuntu-trusty-64:~$ exit
logout
Connection to 127.0.0.1 closed.
设置私有网络,这样可以通过在主机输入特定ip连接到虚拟机的网页
打开rails-va/Vagrantfile文件,在刚刚添加的三行下面,添加一行代码
config.vm.network "private_network", ip: "192.168.33.10"
运行vagrant reload,重新加载vagrant
xuzhaoning@localhost:~/rails-va$ vagrant reload
这时候可能会出现错误
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
解决方法:
打开VirtualBox界面,设置—网络—连接方式改成内部网络
在重新运行vagrant reload即可
安装完成后在虚拟机上安装ruby on rails环境,在下面帖子里有
更多推荐
所有评论(0)