Why does Apache server only work if I have an Internet connection?

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?

Verrtex

Posted 2009-10-07T21:19:15.363

Reputation:

Question was closed 2010-09-07T21:08:08.257

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 – 2009-10-07T21:21:28.583

Sounds like apache is not listening to localhost, rather your network IP. See my comments below. – randomx – 2009-10-07T21:28:39.430

Should we assume you are trying to access the site through http://localhost?

– None – 2009-10-07T21:30:26.617

serverfault.com? – GrzegorzOledzki – 2009-10-07T21:33:04.023

probably should be moved to serverfault – randomx – 2009-10-08T12:11:22.087

Answers

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

randomx

Posted 2009-10-07T21:19:15.363

Reputation: 321

@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. – None – 2009-10-08T18:37:24.273