1

i completely got something wrong abotu the listen thing in apache. my question now is. when i make it listen to

NameVirtualHost *:80
Listen 127.0.0.1:80
Listen 192.168.1.23:80

will it be accessible trough the web? because my internet is connected to 192.168.1.23:80

1 Answer 1

1

Check with netstat that apache is listening on port 80.

% sudo netstat -apn|grep :80
tcp        0      0 :::80                       :::*                        LISTEN      1318/httpd          

Also make sure that you do not have any firewall rules blocking this access, specifically you should have ACCEPT rules on the INPUT chain for http.

% sudo iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED 
ACCEPT     icmp --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:ssh 
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:http 
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited 

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited 

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination 

You can temporarily disable your firewall to confirm with this:

% /etc/init.d/iptables stop

So then the firewall looks like this:

% sudo iptables -L
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         

I would also check out the Apache error and access logs files, most linuxes store these under /var/log, possibly /var/log/httpd. They're usually 2 files, error_log and access_log.

Regarding the error you're getting on startup, sounds like you need to set the ServerName variable in your httpd.conf file.

ServerName localhost

This seems to be an issue with apache2 on Ubuntu. I found several threads on other sites where the solution was to set ServerName to localhost.

13
  • i edited my sudo netstat -apn|grep :80 output above, of course apache2 listens to my localhost. i told you its working. sorry but how is thsi supposed to help me? the access log of course shows access form localhost but i cant even start apache2 with the setting i want so of course there is nothing about failed connections from another ip(my laptop) in there! and its seems that i have no iptables firewall runnning, its sais the file nto exist. and why sould a firewall by default block lan ip adresses? and even if i can't even start apache2 with that config it cant even LISTEN and wait for
    – user150716
    Jan 25, 2013 at 16:28
  • ... something to block. So again the question, how is all this supposed to help me? you seen to not get that apache2 is not starting with that config!
    – user150716
    Jan 25, 2013 at 16:29
  • and reganding the servername, usually it says automatically sets 127.0.0.1 and its working but this sets 127.0.1.1 i just saw. thats mybe the problem. so what sould i set my servername to? 127.0.0.1 or my local lan ip 192.168.0.23?
    – user150716
    Jan 25, 2013 at 16:37
  • well if i set a server name the warning disappears but the actual error stays. still i dont know what to actaully set as sever name, i read somewhere that its normal for localhost and it was defaulting to 127.0.0.1 before and it working great, strangely it defaults to 127.0.1.1 when i add the other listens in. And no there is no typo, there is not a single 127.0.1.1 in my entire /etc/apache2 folder
    – user150716
    Jan 25, 2013 at 16:47
  • my hosts file has a lot of virtual hosts redirected to 127.0.0.1 and ifconfig shows that my pc lan adress is 192.168.1.23 and how is that supposed to help me? that has nothing to do with apache!
    – user150716
    Jan 26, 2013 at 7:29

You must log in to answer this question.