Serving from a Virtual Box Machine

Blog ยป Serving from a Virtual Box Machine

Posted on 04 Jun 2009 09:41

vbox_logo2_gradient.png

Your virtual machine on VirtualBox can be a server. Let's say you have a virtual machine named "My Server". Execute the script below on your host (not the virtual machine):

VBoxManage setextradata "My Server" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol" TCP
VBoxManage setextradata "My Server" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort" 22
VBoxManage setextradata "My Server" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort" 2222

VBoxManage setextradata "My Server" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol" TCP
VBoxManage setextradata "My Server" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort" 3000
VBoxManage setextradata "My Server" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort" 3000

Now you are able to ssh into the virtual machine:

ssh localhost -p 2222

And you can browse the web service on port 3000

firefox http://localhost:3000

Err, what is port 3000? The default port for rails of course. I am testing the Ruby on Rails deployment on a virtual machine.

You've got the idea. Map your ports as you wish.

You will always have a fresh machine for setup tests with VirtualBox VirtualBox. Experience has shown me that you cannot debug deployment on an already installed development machine.

If you like this page, please spread the word: diggdel.icio.usFacebook

You can contact me if you have questions or corrections.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License