Linux – How to access http://localhost on the host operating system if the server is in a virtual machine

linuxlocalhostweb-developmentwebserver

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?

Best Answer

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.

Related Question