Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Possible Duplicate:
Apache w/out internet connection

I have installed Apache server on my local machine and managed to see local PHP files with my browser. However, later I found out that I cannot do it if I have no Internet connection. In other words, is it true that Apache cannot display files on my computer if I have no Internet connection? Why does it need Internet to read from the local hard disc? And how I can overcome this limitation?

share|improve this question

migrated from stackoverflow.com Sep 7 '10 at 21:06

This question came from our site for professional and enthusiast programmers.

marked as duplicate by Diago Sep 7 '10 at 21:08

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
That sounds totally bizarre; hopefully, Apache is configured to listen on the local loopback adapter and isn't depending upon some other network interface being up. What actually happens, in terms of browser output, when you try and serve up a PHP file without a connection? –  Rob Oct 7 '09 at 21:21
    
Sounds like apache is not listening to localhost, rather your network IP. See my comments below. –  randy melder Oct 7 '09 at 21:28
    
Should we assume you are trying to access the site through localhost? –  James Goodwin Oct 7 '09 at 21:30
    
serverfault.com? –  GrzegorzOledzki Oct 7 '09 at 21:33
    
probably should be moved to serverfault –  randy melder Oct 8 '09 at 12:11

1 Answer 1

In your /etc/hosts file, append your virtualhost servernames to the end of the localhost line. e.g.:

127.0.0.1   localhost www.domain.tld www.otherdomain.tld

In your httpd.conf, enter this:

Listen 80 
# make sure all other listen lines are commented out.
NameVirtualHost *:80

In your vhost config files, structure like this:

<VirtualHost *:80>
ServerName www.domain.tld
DocumentRoot /www/domain
</VirtualHost>

<VirtualHost *:80>
ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain
</VirtualHost>

http://httpd.apache.org/docs/2.0/vhosts/name-based.html http://httpd.apache.org/docs/1.3/vhosts/name-based.html

share|improve this answer
    
@randy melder: instead of having one <VirtualHost> tag for each ServerName, you could have a single <VirtualHost> tag and add a ServerAlias for each additional hostname. –  Asaph Oct 8 '09 at 18:37