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 Answers1

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.

slm
  • 7,355
  • 16
  • 54
  • 72
  • 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 –  Jan 25 '13 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! –  Jan 25 '13 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? –  Jan 25 '13 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 –  Jan 25 '13 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! –  Jan 26 '13 at 07:29
  • i also just figured out that ubuntu in fact has iptables running and your command was wrong, i disabled it temporally but as expecte no difference! sorry but it seems you have no idea what you talking about because you treat me as if apache2 would start and i would just fail to connect to it. what about the fact that its not even starting with that config? this to my locical thinking cant have anything to do with hosts file, firewall or other things you mentioned –  Jan 26 '13 at 07:43
  • Please watch your tone, your comment is a little offensive. I'm the only one attempting to help you, so show some gratitude! Can you please run the command `sudo hostname`? What does it show? – slm Jan 26 '13 at 09:45
  • This ubuntuforum thread shows someone with the same issue you're experiencing: http://ubuntuforums.org/archive/index.php/t-215349.html – slm Jan 26 '13 at 09:48
  • Please delete some of the comments above that are no longer relevant. – slm Jan 26 '13 at 10:00
  • well i was a little offensive because i meant to be and there is no reason for me to watch my tone here. how about you delete your andwer because it want not on point, did not help me and its no longer relevant. i helped my self with google and changed my question above. i did andswer this myself and now the andwer is gone? did you have anything to do with this? – James Mitch Jan 27 '13 at 03:44
  • No I had nothing to do with it. I'm sorry you feel this way. This is a community site where others are trying to help you. I'm sorry you have so much anger and frustration at others that are only trying to help you. – slm Jan 27 '13 at 04:04
  • :@JamesMitch are you the same person as Lonelyisland? It seems odd that you should respond they way that you have if you're not. There are other pieces of information which suggest the same too. – user9517 Jan 27 '13 at 08:26
  • @JamesMitch"_well i was a little offensive because i meant to be and there is no reason for me to watch my tone here._" It is really a bad idea to offend, insult, or antagonize the people trying to help you. Everyone here is a volunteer, and none owe you any help. You should actually be grateful that someone took an interest and is trying to help. Such an attitude can end up with all your questions being ignored. After all, SE rule #1 is, "Be nice!" – Ron Maupin May 31 '21 at 03:27