Ubuntu: apache2 on ubuntu 14 - localhost works but ip doesn't



Question:

I've just installed apache2 on my box, along with php5.

I can navigate to "localhost" and it works. But I can't access this webserver from another machine... or even locally using the IP address. Other posts such as Apache (and other services) work on localhost, but not IP address suggest firewall settings and also checking to make sure I'm listening not just on localhost but *80.

This is what I have in ports.conf:

me@mydev:/etc/apache2$ cat ports.conf   # If you just change the port or add more ports here, you will likely also  # have to change the VirtualHost statement in  # /etc/apache2/sites-enabled/000-default.conf    Listen 80    <IfModule ssl_module>   Listen 443 </IfModule>    <IfModule mod_gnutls.c>     Listen 443 </IfModule>    # vim: syntax=apache ts=4 sw=4 sts=4 sr noet   

The default firewall doesn't seem to be enabled:

me@mydev:/etc/apache2$ sudo ufw status  [sudo] password for me:   Status: inactive  me@mydev:/etc/apache2$   

Just not sure what else I should check. Thanks.

EDIT 1

Results from IP tables query:

me@mydev:/etc/apache2$ sudo iptables -L [sudo] password for me: Chain INPUT (policy ACCEPT) target prot opt source
destination

Chain FORWARD (policy ACCEPT) target prot opt source
destination

Chain OUTPUT (policy ACCEPT) target prot opt source
destination me@mydev:/etc/apache2$

And I am able to successfully ping the box from different machines.

EDIT 2

Here are the results from the nmap command:

me@mydev:/var/www/html/test$ nmap localhost    Starting Nmap 6.40 ( http://nmap.org ) at 2014-12-01 04:04 EST  Nmap scan report for localhost (127.0.0.1)  Host is up (0.00020s latency).  Not shown: 997 closed ports  PORT    STATE SERVICE  22/tcp  open  ssh  80/tcp  open  http  631/tcp open  ipp    Nmap done: 1 IP address (1 host up) scanned in 0.04 seconds  me@mydev:/var/www/html/test$   

And for the IP:

me@mydev:/var/www/html/test$ nmap 10.238.59.63    Starting Nmap 6.40 ( http://nmap.org ) at 2014-12-01 04:08 EST  Nmap scan report for mydev.testdomain.bg.org (10.238.59.63)  Host is up (0.00024s latency).  Not shown: 998 closed ports  PORT   STATE SERVICE  22/tcp open  ssh  80/tcp open  http    Nmap done: 1 IP address (1 host up) scanned in 0.04 seconds  me@mydev:/var/www/html/test$   


Solution:1

This isn't actually an answer, but it was too detailed to be a comment, and may become an answer after more information is determined.

When I read your post, I thought you were using your lan ip address (internal ip address), but after comparing the results of your commands vs my own, forcing me to look more closely, I see that you are trying to use an external public ip address.

This situation results in more variables and more complexity.

Are you using the actual ip address (xxx.xxx.xxx.xxx), or the domain name?

Is "mydev.testdomain.bg.org" the actual domain name? I don't see this in the registry at all - how are you getting the DNS?

Does your apache configuration file have the ServerName specified in the VirtualHost setup in /etc/apache2/sites-enabled?

What sort of system is this hosted on? I've seen situations with certain routers where you couldn't access a local site from the local machine using the external public ip (for example, Comcast's router).

EDIT: Also, when you make changes to your configuration, as suggested by people who may or may not have a clue about what they are suggesting, and the change does not solve your problem, do you go back and undo the change to restore the original configuration? You should either do that, or keep very good records about all the changes you've made.


Solution:2

If you are using a VM, just try restarting it!!

I had the exact same problem with the same configurations you had in a fresh install of Ubuntu. localhost was working but nothing else. A restart solved it for me.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »