3

I'm trying to set up a development environment for a javascript web application using apache, but I can't seem to do even the simplest of things, like setting up a virtual host to serve the static html, js, and other file types.

Here's what I'm trying to do in httpd-vhosts.conf:

<VirtualHost *:80>
    ServerAdmin test@localhost
    ServerName www.nonlocal-blight.com
    ServerAlias www.local-blight.com

    DocumentRoot "/Apache24/documents/WebContent"
    <Directory "WebContent">
        Options Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>

</VirtualHost>

I've got an index.html file in WebContent, but whether I try to go to www.local-blight.com, or www.local-blight.com/index.html, I always get "Oops! Google Chrome could not find [whatever]". I've tried removing the ServerAlias, a different folders for the Document root, removing the line Options Indexes FollowSymLinks and everything.

I've tried using httpd.exe -S to check my virtual host configuration, but so far as I can see, the output looks good:

C:\Apache24\bin>httpd.exe -S
VirtualHost configuration:
*:80                   is a NameVirtualHost
         default server www.nonlocal-blight.com (C:/Apache24/conf/extra/httpd-vh
osts.conf:37)
         port 80 namevhost www.nonlocal-blight.com (C:/Apache24/conf/extra/httpd
-vhosts.conf:37)
                 alias www.local-blight.com
         port 80 namevhost www.nonlocal-blight.com (C:/Apache24/conf/extra/httpd
-vhosts.conf:37)
                 alias www.local-blight.com
*:443                  is a NameVirtualHost
         default server localhost (C:/Apache24/conf/extra/httpd-sni.conf:134)
         port 443 namevhost localhost (C:/Apache24/conf/extra/httpd-sni.conf:134
)
         port 443 namevhost localhost (C:/Apache24/conf/extra/httpd-sni.conf:134
)
         port 443 namevhost serverone.tld (C:/Apache24/conf/extra/httpd-sni.conf
:151)
         port 443 namevhost serverone.tld (C:/Apache24/conf/extra/httpd-sni.conf
:151)
         port 443 namevhost servertwo.tld (C:/Apache24/conf/extra/httpd-sni.conf
:166)
         port 443 namevhost servertwo.tld (C:/Apache24/conf/extra/httpd-sni.conf
:166)
ServerRoot: "C:/Apache24"
Main DocumentRoot: "C:/Apache24/documents"
Main ErrorLog: "C:/Apache24/logs/error.log"
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
Mutex ssl-cache: u

sing_defaults
Mutex default: dir="C:/Apache24/logs/" mechanism=default
PidFile: "C:/Apache24/logs/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
Define: SRVROOT=/Apache24

Can anyone tell me what I'm doing wrong here?

CorayThan
  • 17,174
  • 28
  • 113
  • 161
  • 1
    Always the first point where to start is the http servers log files. Check what requests are actually made to the server in the 'access' log file and compare what error is reported in the 'error' log file. – arkascha Aug 20 '13 at 07:59
  • There's nothing in either. When I try to go to `www.local-blight.com` I get no access logs and no error logs. – CorayThan Aug 20 '13 at 08:06
  • 1
    So obviously the requests are not targetting your http server at all. Sounds like a name resolution problem. Or might it be that you are blocking requests by a firewall? Test by making a telnet request to the http server: `telnet www.nonlocal-blight.com http`. Does it get rejected or does it connect? – arkascha Aug 20 '13 at 08:09
  • It gets rejected: `Connecting To www.nonlocal-blight.com...Could not open connection to the host, on port http: Connect failed`. I tried turning off windows firewall (the only firewall I use) but that didn't change the results. – CorayThan Aug 20 '13 at 08:17
  • 1
    1.) is the http server running at all? Did you reload it after changing the configuration? 2.) can you connect to the http server when using a ip address instead of the name? 3.) what address does the name "www.nonlocal-blight.com" actually resolve to on your system? – arkascha Aug 20 '13 at 08:20
  • I think you've started to set me on the right track! I went and added `127.0.0.1 www.local-blight.com` to my windows hosts file, and now when I try to go to `www.local-blight.com` I get a `403 Forbidden`, and the error logs actually log stuff. – CorayThan Aug 20 '13 at 08:32
  • Eureka! [This question](http://stackoverflow.com/questions/10351167/apache-client-denied-by-server-configuration) had an answer for why I was getting 403s, and now it seems to be working. Thank you! If you want to make your suggestion into a question I'll accept it. – CorayThan Aug 20 '13 at 08:44
  • Glad I could help. I don't try to push some stupid points counter up here, so never mind. – arkascha Aug 20 '13 at 08:58

1 Answers1

2

I needed to add the line:

127.0.0.1 www.local-blight.com

To my windows hosts file in %SystemRoot%\system32\drivers\etc\hosts.

I also needed to follow this answer to permit my system to access the files through a browser.

Community
  • 1
  • 1
CorayThan
  • 17,174
  • 28
  • 113
  • 161