Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I always used XAMPP for my LAMP environment and developed directly on Windows 7. But now I want to do all my web development on Linux so I installed Ubuntu in virtualbox and installed PHP/MySQL and Apache individually.

I can access everything in the browser inside my VM, but now I want to access http://localhost in Windows. How can I do this, I assume it should be easy enough since both OS's are in the same internal network?

share|improve this question

migrated from serverfault.com Oct 22 '11 at 1:52

This question came from our site for system and network administrators.

2 Answers 2

As far as your Windows machine is concerned, the Ubuntu webserver in VirtualBox is a completely separate computer. 'localhost' won't work. So long as the Ubuntu Apache is binding eth0, you should be able to access the Ubuntu-based site via direct IP. http://172.16.12.34/ for example.

You can find the IP of the Ubuntu install a couple of ways. /sbin/ifconfig eth0 being one of them. Use that IP address in the URL instead of localhost.

share|improve this answer
    
You can also try opening ipchicken.com in the Internet browser on the VM. –  DragonLord Oct 22 '11 at 3:41

VirtualBox provides several networking modes for attaching guests to the host machine. The default is NAT which by default does not expose the guest to the host. Check out which mode you are using by going to the settings window for your VM and clicking on the network tab. You'll see the Attached: property followed by a drop box.

If you're using the NAT mode we can use port forwarding to expose port 80 on the guest. Open the Advanced section on the networking settings window and click the Port Forwarding button. On the resulting dialogue we want to add an entry. Let's name it Web, the protocol will be TCP the host port can be any port you want to connect to on your windows box. Let's make it 80. The guest port needs to be 80 as that's what your web server is listening to on your linux guest VM. The Host IP and Guest IP can be left blank. Click OK for the dialogue and the setting window. Start up your VM and you should be able to connect to http://localhost from your windows machine.

For more information about how VirtualBox handles networking check out the documentation at http://www.virtualbox.org/manual/ch06.html

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.