0

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?

5
  • 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
    Commented Oct 7, 2009 at 21:21
  • Sounds like apache is not listening to localhost, rather your network IP. See my comments below.
    – randomx
    Commented Oct 7, 2009 at 21:28
  • Should we assume you are trying to access the site through localhost?
    – James Goodwin
    Commented Oct 7, 2009 at 21:30
  • serverfault.com? Commented Oct 7, 2009 at 21:33
  • probably should be moved to serverfault
    – randomx
    Commented Oct 8, 2009 at 12:11

1 Answer 1

3

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

1
  • @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
    Commented Oct 8, 2009 at 18:37