5

I am new to Ubuntu and have Apache2 running in a virtual box on my machine. I am trying to access this server on my Windows machine.. I am assuming that I need to find the ipAddress and the port to access the server.

I have tried Identifying my IpAddress using the following

lfconfig

enter image description here

enter image description here

And then checking which port Apache is running

lsof -i etc..

enter image description here

I'm not really sure what all this information means.. But I am assuming that If I find the Ip Address and port I can navigate to it on my windows pc. e.g. http://10.0.2.15:27017

Anyway I have tried just about every cominbation of ipAdress/port listed and can't figure it out.

Do I need to implement any port forwarding? I found the following screen in my vm settings but don't know what to try from there.

enter image description here

Would appreciate any direction or guidance on how I can access the apache2 server.

0

2 Answers 2

5

There are a number of factors at play, mainly your Apache configuration and the network setup of your VM.

You are on the right track with the Apache setup, but I would use netstat to find the port your Apache is listening to:

gomo@wks120:~/$ sudo netstat -puant | grep apache | grep LISTEN
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      1577/apache2    
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      1577/apache2

This shows I have a process called apache2 with PID 1557 listening on port 80 and 443 on all interfaces (0.0.0.0).

For the network setup part, it depends on what type of networking you are using for your virtual machine (found in VirtualBox under each VM's Settings --> Network page. The most common options are either bridged or NAT.

Bridged means the VM will be granted access to the physical network your host computer is connected to. Things would work as if you plugged the VM onto the same switch your computer is plugged in to. You typically run virtualized servers this way.

NAT means a local network will be created just for your VMs. This is similar to how your average home router/wireless AP works: VMs can access outside networks (such as your LAN or the internet) but other computers can't reach your VMs.

All in all, set up bridged networking (restart the VM's network or the entire VM after changing this) and check your apache port. You should be able to connect without problems from your host machine.

3
  • This said, unless you changed something, it's pretty much 100% certain that your Apache is listening on port 80. If you "sudo grep -rni listen" in /etc/apache2/ you should find the relevant configuration directives.
    – GomoX
    Jan 10, 2014 at 15:06
  • Thank you for your answer, I'll follow your advice when I get a chance to work on it this weekend and will get back to you or accept your answer.
    – Trevor
    Jan 10, 2014 at 15:51
  • Thanks again, your explanation of the Bridged and Nat options helped a lot! I was able to access the server :)
    – Trevor
    Jan 11, 2014 at 4:13
-1

Stop your VM and open its settings in the VirtualBox (OSE) Manager Go to the Network tab Select the network mode to host-only

Save the settings Start the Ubuntu VM

1
  • Why do you think that "host only" is appropriate here?
    – guntbert
    Dec 26, 2015 at 19:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .