2009-12-10

VirtualBox strange port-80 forwarding

Task: Develop iPhone-adapted webpage in VirtualBox Gnu/Linux virtual machine. Test it from an iPhone. Get up quick.

OS X has a built in Apache. VirtualBox can share folders. Let Apache serve a shared folder, then the iPhone can surf to the Mac and I can develop in Gnu/Linux.

System > Sharing > Web Sharing turns on Apache.

/Library/WebServer/Documents contains index.html.en. Rename to hello.html. Now if you go to localhost you will see a list of files instead of It Works!

Make a folder (I called it vbox-web).

Go to VirtualBox, shared Folders. Add this folder, click make-permanent.

On the virtual machine:
sudo mkdir /mnt/vbox-web
sudo mount -t vboxsf vbox-web /mnt/vbox-web/

Ok, this does not work perfectly, I can't use symlinks and I have to work as a root. But it is a start, I can surf with the iPhone and develop on the virtual machine which is what I wanted.

Apprently from the VirtualBox Faq you should add some parameters to the mount command to make it work better.
Improved command:
sudo mount -t vboxsf -o uid=1000,gid=1000 vbox-web /mnt/vbox-web/

Also, not that if you want to do this each time it should not be added to fstab but to a script (see faq).

No comments:

Post a Comment