ocpaul20 Posted November 2, 2011 Share Posted November 2, 2011 I have a problem with configuring Apache httpd.conf and the hosts file. As I understand it the server name in httpd:conf should open a local website in the browser as long as there is hosts entry for it. However, this is not working for me and I must be missing something very simple. my hosts file has one line in it 127.0.0.1 debhost localhost develop.lcl my httpd.conf file has at the top ServerRoot "/opt/lampp" Listen 127.0.0.1:80 and then further down ServerName develop.lcl <Directory /home/weifan/httpd/> Options Indexes FollowSymLinks ExecCGI Includes AllowOverride All Order allow,deny Allow from all </Directory> DocumentRoot "/home/weifan/httpd/newdevelop/httpdocs/" The result is that in the browser, http://localhost brings up the index.php for the correct docroot (as above) BUT http://develop.lcl in the browser, tries to go to the internet to retrieve this URL address and does not look for it locally as per the hosts file. It cannot find the same index.php as localhost does. I thought that the hosts file would tell Apache that this website was local (127.0.0.1) why isn't this working please? I must be missing a vital aspect of this puzzle. Please can someone shed light for me? Have I explained it clearly enough? Thanks Paul Quote Link to comment https://forums.phpfreaks.com/topic/250280-apache-local-domain-configuration-issue/ Share on other sites More sharing options...
trq Posted November 2, 2011 Share Posted November 2, 2011 The hosts file has nothing to do with Apache. Can you ping develop.lcl ? Quote Link to comment https://forums.phpfreaks.com/topic/250280-apache-local-domain-configuration-issue/#findComment-1284195 Share on other sites More sharing options...
ocpaul20 Posted November 2, 2011 Author Share Posted November 2, 2011 This is my understanding of the hosts file. The browser looks in the hosts file to find any entries for the requested domain, and if found, it uses thoat IP address instead of doing a DNS lookup on the internet. There has to be an entry in the hosts file for any local machine domains - like develop.lcl is. Is that not how it works? Anyway, any help on my issue would be gratefully received. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/250280-apache-local-domain-configuration-issue/#findComment-1284204 Share on other sites More sharing options...
trq Posted November 2, 2011 Share Posted November 2, 2011 That is roughly how it works. Any request your computer makes to some domain will first check the hosts file for this domain and it's related ip. If it find a match, it will request that ip, otherwise it will query whatever name server it is configured to listen to. That siad, you didn't answer my only question. Quote Link to comment https://forums.phpfreaks.com/topic/250280-apache-local-domain-configuration-issue/#findComment-1284210 Share on other sites More sharing options...
ocpaul20 Posted November 2, 2011 Author Share Posted November 2, 2011 No it doesn't ping. It tries to go to the web to read it from an outside ip address(202....). (could be my machines allocated internet IP address). Anyway from the hosts file, I would have expected it to resolve to 127.0.0.1 wouldn't you? Actually In a roundabout way I did - I said that the browser tries to go externally to resolve this domain instead of using the hosts file and then being directed to 127.0.0.1 pinging localhost does go to 127.0.0.1 though. Quote Link to comment https://forums.phpfreaks.com/topic/250280-apache-local-domain-configuration-issue/#findComment-1284211 Share on other sites More sharing options...
trq Posted November 2, 2011 Share Posted November 2, 2011 If develop.lcl is not resolving to 127.0.0.1 there is something wrong with your hosts file entry. try placing it on a separate line: 127.0.0.1 develop.lcl What OS are you using? Quote Link to comment https://forums.phpfreaks.com/topic/250280-apache-local-domain-configuration-issue/#findComment-1284212 Share on other sites More sharing options...
ocpaul20 Posted November 3, 2011 Author Share Posted November 3, 2011 I have been an ass. There was more than one copy of hosts file and even though the #whereis hosts command only found my hosts file, there was another. I thought I had all the correct links in place but I didnt. As with a lot of these things it is just a matter of methodically going through everything and double checking. Thank you for your time in replying and I apologise for wasting it. I am using Debian Squeeze Quote Link to comment https://forums.phpfreaks.com/topic/250280-apache-local-domain-configuration-issue/#findComment-1284503 Share on other sites More sharing options...
trq Posted November 3, 2011 Share Posted November 3, 2011 There should only be 1 hosts file (/etc/hosts) on squeeze, where is this other one located? Quote Link to comment https://forums.phpfreaks.com/topic/250280-apache-local-domain-configuration-issue/#findComment-1284527 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.