Jump to content

Recommended Posts

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

 

Link to comment
https://forums.phpfreaks.com/topic/250280-apache-local-domain-configuration-issue/
Share on other sites

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.

 

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.

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.

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.