How to access web server running on a VM

Discussions about using Linux guests in VirtualBox.
Post Reply
hammerhead1024
Posts: 8
Joined: 24. Sep 2010, 05:35
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: CentOS

How to access web server running on a VM

Post by hammerhead1024 »

Greetings,

Not sure if this is the proper forum for this. I have VirtualBox installed on a Windows 7 Pro host. I created a VM and installed Linux CentOS on it. I want to use it as a web server so I installed Apache httpd. I tested it by starting Firefox browser on the CentOS, entered http://127.0.0.1, and the test page popped up. I tried to access it from another PC on my home lan by specifying the IP address for the Linux system (10.0.2.15) but it wouldn’t connect.

To verify it wasn’t something with my router I started Windows web server software (IIS) on the Windows 7 and on another PC specified the IP address of the Windows 7 PC and the IIS test page did pop up.

So what do I have to do to access the Linux web server from another PC?

Thanks.
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: How to access web server running on a VM

Post by Perryg »

You should read chapter 6 of your VirtualBox users guide. Pay particular attention to the port forwarding section when using NAT.
oszone
Posts: 2
Joined: 12. Apr 2011, 16:04
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: Ubuntu, xp sp2

Re: How to access web server running on a VM

Post by oszone »

But is there away to connect to guest os' web server by IP? so I could set hostname for it?
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: How to access web server running on a VM

Post by Perryg »

Yes.
Select Bridged if there is a router in the network or host-only if there is not for the #1 adapter.
Add #2 adapter and set it to NAT if using host-only and you need Internet access in the guest.
oszone
Posts: 2
Joined: 12. Apr 2011, 16:04
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: Ubuntu, xp sp2

Re: How to access web server running on a VM

Post by oszone »

When I choose host only, there is nothing to select in "Name" section and ai cannot save.
hammerhead1024
Posts: 8
Joined: 24. Sep 2010, 05:35
Primary OS: MS Windows 7
VBox Version: OSE other
Guest OSses: CentOS

Re: How to access web server running on a VM

Post by hammerhead1024 »

Perryg wrote:You should read chapter 6 of your VirtualBox users guide. Pay particular attention to the port forwarding section when using NAT.
Thanks much for pointing me to the right doc. I entered this command in a host's DOS window:

Code: Select all

"c:\program files\oracle\virtualbox\vboxmanage" modifyvm "LinuxSys1" --natpf1 "guestweb,tcp,,2222,,80"
Booted the VM and was able to access the guest web server from a host browser with address: http://127.0.0.1:2222
manikaedore
Posts: 2
Joined: 13. Apr 2011, 14:24
Primary OS: MS Windows XP
VBox Version: OSE Debian
Guest OSses: win7

Re: How to access web server running on a VM

Post by manikaedore »

I think you can just use to set the NAT on using host-only. This could have an access on web server. It needs some other settings on the server to do that and accessing through IP address.
Post Reply