ubuntu14.03-server-rails.box
都下载安装好之后,我们需要配置一下 cmder
Cmder.exe /REGISTER ALL
,这样以后我们可以在任意文件点击鼠标右键可以看到cmder here
到此为止cmder必须的配置已经搞定
我们可以开工了。
ubuntu14.03-server-rails.box
:
vagrant box add ubuntu-rails ubuntu14.03-server-rails.box
,ubuntu-rails 是生成系统的名字,这里我的 cmder 已经切换到ubuntu14.03-server-rails.box
所在的目录下mkdir workspace
cd workspace
mkdir ubuntu-rails
cd ubuntu-rails
vagrant init ubuntu-rails
接下来可以直接启动系统了
vagrant up
vagrant ssh
到了这一步,你就可以看到,你的系统已经不再是你的 win 系统而是你的 ubuntu 系统D:\workspace\ubuntu-rails (master)
λ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 3000 (guest) => 3001 (host) (adapter 1)
default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
default: The guest additions on this VM do not match the installed version of
default: VirtualBox! In most cases this is fine, but in rare cases it can
default: prevent things such as shared folders from working properly. If you see
default: shared folder errors, please make sure the guest additions within the
default: virtual machine match the version of VirtualBox you have installed on
default: your host and reload your VM.
default:
default: Guest Additions Version: 5.0.8
default: VirtualBox Version: 5.1
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
default: /vagrant => D:/workspace/ubuntu-rails
default: /home/vagrant/workspace => D:/workspace/ubuntu-rails
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
D:\workspace\ubuntu-rails (master)
λ vagrant ssh
Welcome to Ubuntu 14.04.3 LTS (GNU/Linux 3.19.0-25-generic x86_64)
* Documentation: https://help.ubuntu.com/
System information as of Sat Dec 10 18:56:48 CST 2016
System load: 0.74 Processes: 88
Usage of /: 34.1% of 6.76GB Users logged in: 0
Memory usage: 9% IP address for eth0: 10.0.2.15
Swap usage: 0% IP address for eth1: 192.168.33.10
Graph this data and manage this system at:
https://landscape.canonical.com/
179 packages can be updated.
126 updates are security updates.
New release '16.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it.
Last login: Sat Dec 10 16:33:37 2016 from 10.0.2.2
vagrant@ubuntu:~$ ls
workspace
vagrant@ubuntu:~$ cd workspace/myblog/
vagrant@ubuntu:~/workspace/myblog$ rails s
=> Booting WEBrick
=> Rails 4.2.4 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2016-12-10 18:58:40] INFO WEBrick 1.3.1
[2016-12-10 18:58:40] INFO ruby 2.2.1 (2015-02-26) [x86_64-linux]
[2016-12-10 18:58:40] INFO WEBrick::HTTPServer#start: pid=2699 port=3000
这样我们的项目就跑起来了,不过这样跑起来,浏览器并不能与我们的服务互动。我们需要一点小操作:
我们在启动服务的时候,不要用 localhost 这个主机
我们需要指定主机
rails s -b 0.0.0.0
这样服务跑起来是:
vagrant@ubuntu:~/workspace/myblog$ rails s -b 0.0.0.0
=> Booting WEBrick
=> Rails 4.2.4 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2016-12-10 19:05:06] INFO WEBrick 1.3.1
[2016-12-10 19:05:06] INFO ruby 2.2.1 (2015-02-26) [x86_64-linux]
[2016-12-10 19:05:06] INFO WEBrick::HTTPServer#start: pid=2710 port=3000
然后我们可以在我们 windows 下的浏览器中访问我们的服务了
http://localhost:3001
浏览器访问的时候用的端口是:3001
上面vagrant up
启动虚拟机的时候已经告知:
==> default: Forwarding ports...
default: 3000 (guest) => 3001 (host) (adapter 1)
default: 22 (guest) => 2222 (host) (adapter 1)
在 cmder 中切换 windows 下路径可以 cd ..
不过如果更换根目录的时候需要类似 cd /d D:\download
这个/d
不可省略,或者用pushd D:\download
下载好了sublime text 3之后我们需要实现 subl .
启动文件的功能
打开 Cmder 安装目录下的 config 文件夹下的 aliases 文件。
在 aliases 中增加一行,添加别名。
subl="D:\PROGRA~1\sublimeText3\sublime_text.exe"
如果你的屏幕足够大或者你分辨率足够高你可以选择
subl="D:\PROGRA~1\sublimeText3\sublime_text.exe" $1 -new_console:s50H
这样你左边是终端,右边是 sublime
这样你已经可以很舒服地在 windows 下开发了,还有一些小细节,可以参考相关文献
第一次用这个 windows 下的 sublime,全局搜索快捷键ctrl + shift + f
,无法使用