logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Virtual Hosts work but not localhost
Author
Mike-H



Joined: 29 Dec 2008
Posts: 16

PostPosted: Wed 07 Oct '09 23:42    Post subject: Virtual Hosts work but not localhost Reply with quote

Hi,

I recently installed apache and php on a second laptop computer for testing & development. I created a directory to hold all my virtual hosts and so far I have been able to access the 2 v-hosts I have created. But I am unable to access anything via localhost (http://localhost). The files are in a directory called c:/LocalhostWebPages. httpd.conf contains the following line:

DocumentRoot "C:/LocalhostWebPages".

I have tried accessing the localhost, an html index file and a php index file, nothing will work. I think I must have something else in the httpd.conf file that is amiss, but I am not seeing it. Does anyone have any ideas?

Thank you,
Mike
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Thu 08 Oct '09 1:32    Post subject: Reply with quote

so exactly what happens when you go to http://localhost?
Does the browser timeout or you get one of the two v-hosts?
Back to top
Mike-H



Joined: 29 Dec 2008
Posts: 16

PostPosted: Thu 08 Oct '09 15:04    Post subject: Reply with quote

Sorry to have omitted that little detail Embarassed

When I type http://localhost in the address bar I get

"Forbidden
You don't have permission to access / on this server."

When I type http://localhost/index.html in the address bar, I get:

"Forbidden
You don't have permission to access /index.html on this server."

Does this point to anything?
Thanks for your help.

Mike
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Thu 08 Oct '09 17:07    Post subject: Reply with quote

Most definately

Whatever you have as a DocumentRoot there needs to be a corresponding <Directory /path/to/docroot> that goes with it.


DocumentRoot "C:/LocalhostWebPages"
<Directory "C:/LocalhostWebPages">
Options whatever see manual
AllowOverride whatever see manual
Order Allow,Deny
Allow from all
</Directory>

see
http://httpd.apache.org/docs/2.2/mod/core.html#directory
http://httpd.apache.org/docs/2.2/mod/core.html#options
http://httpd.apache.org/docs/2.2/mod/core.html#allowoverride
Back to top
Mike-H



Joined: 29 Dec 2008
Posts: 16

PostPosted: Thu 08 Oct '09 22:39    Post subject: Reply with quote

Thanks, but there must be some other problem. The following is in the httpd.conf file:

DocumentRoot "C:/LocalhostWebPages"

<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>

<Directory "C:/LocalhostWebPages">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>

... snip ... (comments omitted)

I also tried changing the directory for localhost from "C:/LocalhostWebPages" to "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs" in both the DocumentRoot statement and the second <Directory> statement listed above, but this didn't make any difference.

Mike
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Fri 09 Oct '09 20:37    Post subject: Reply with quote

did you restart Apache after making the changes?
Back to top
Mike-H



Joined: 29 Dec 2008
Posts: 16

PostPosted: Fri 09 Oct '09 21:12    Post subject: Reply with quote

Yes, I restart apache every time I make a change to httpd.conf.
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Fri 09 Oct '09 21:21    Post subject: Reply with quote

what is in your error log?
Back to top
Mike-H



Joined: 29 Dec 2008
Posts: 16

PostPosted: Fri 09 Oct '09 21:55    Post subject: Reply with quote

Here is the log from today. The errors seem to come up when I try and restart Apache, nothing is entered when I try to access a localhost web page.

Warning: DocumentRoot [C:/Program Files/Apache Software Foundation/Apache2.2/docs/dummy-host.7422GX] does not exist
Warning: DocumentRoot [C:/Program Files/Apache Software Foundation/Apache2.2/docs/dummy-host2.7422GX] does not exist
[Fri Oct 09 07:28:27 2009] [warn] pid file C:/Program Files/Apache Software Foundation/Apache2.2/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[Fri Oct 09 07:28:28 2009] [notice] Apache/2.2.11 (Win32) PHP/5.2.10 configured -- resuming normal operations
[Fri Oct 09 07:28:28 2009] [notice] Server built: Dec 10 2008 00:10:06
[Fri Oct 09 07:28:28 2009] [notice] Parent: Created child process 1220
Warning: DocumentRoot [C:/Program Files/Apache Software Foundation/Apache2.2/docs/dummy-host.7422GX] does not exist
Warning: DocumentRoot [C:/Program Files/Apache Software Foundation/Apache2.2/docs/dummy-host2.7422GX] does not exist
Warning: DocumentRoot [C:/Program Files/Apache Software Foundation/Apache2.2/docs/dummy-host.7422GX] does not exist
Warning: DocumentRoot [C:/Program Files/Apache Software Foundation/Apache2.2/docs/dummy-host2.7422GX] does not exist
[Fri Oct 09 07:28:29 2009] [notice] Child 1220: Child process is running
[Fri Oct 09 07:28:29 2009] [notice] Child 1220: Acquired the start mutex.
[Fri Oct 09 07:28:29 2009] [notice] Child 1220: Starting 64 worker threads.
[Fri Oct 09 07:28:29 2009] [notice] Child 1220: Starting thread to listen on port 80.
[Fri Oct 09 14:52:27 2009] [notice] Parent: Received restart signal -- Restarting the server.
[Fri Oct 09 14:52:27 2009] [notice] Child 1220: Exit event signaled. Child process is ending.
[Fri Oct 09 14:52:28 2009] [notice] Child 1220: Released the start mutex
Warning: DocumentRoot [C:/Program Files/Apache Software Foundation/Apache2.2/docs/dummy-host.7422GX] does not exist
Warning: DocumentRoot [C:/Program Files/Apache Software Foundation/Apache2.2/docs/dummy-host2.7422GX] does not exist
[Fri Oct 09 14:52:29 2009] [notice] Child 1220: All worker threads have exited.
[Fri Oct 09 14:52:29 2009] [notice] Child 1220: Child process is exiting
[Fri Oct 09 14:52:30 2009] [notice] Apache/2.2.11 (Win32) PHP/5.2.10 configured -- resuming normal operations
[Fri Oct 09 14:52:30 2009] [notice] Server built: Dec 10 2008 00:10:06
[Fri Oct 09 14:52:30 2009] [notice] Parent: Created child process 3744
Warning: DocumentRoot [C:/Program Files/Apache Software Foundation/Apache2.2/docs/dummy-host.7422GX] does not exist
Warning: DocumentRoot [C:/Program Files/Apache Software Foundation/Apache2.2/docs/dummy-host2.7422GX] does not exist
Warning: DocumentRoot [C:/Program Files/Apache Software Foundation/Apache2.2/docs/dummy-host.7422GX] does not exist
Warning: DocumentRoot [C:/Program Files/Apache Software Foundation/Apache2.2/docs/dummy-host2.7422GX] does not exist
[Fri Oct 09 14:52:31 2009] [notice] Child 3744: Child process is running
[Fri Oct 09 14:52:31 2009] [notice] Child 3744: Acquired the start mutex.
[Fri Oct 09 14:52:31 2009] [notice] Child 3744: Starting 64 worker threads.
[Fri Oct 09 14:52:31 2009] [notice] Child 3744: Starting thread to listen on port 80.

Thanks,
Mike
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Fri 09 Oct '09 22:06    Post subject: Reply with quote

Warning: DocumentRoot [C:/Program Files/Apache Software Foundation/Apache2.2/docs/dummy-host2.7422GX] does not exist

obviously you have at least one document root pointing to a place that does not exist in the filesystem.

if you wish post your config at http://apache.pastebin.com
and then post the link here to your config there
Back to top
Mike-H



Joined: 29 Dec 2008
Posts: 16

PostPosted: Fri 09 Oct '09 22:11    Post subject: Reply with quote

http://apache.pastebin.com/m1bb86a12

Hope that will help some.

Thanks,
Mike
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Fri 09 Oct '09 22:39    Post subject: Reply with quote

There is a little caveat in the vhost configuration that is stated in the Docs, I've rarely ever seen it do as it is documented "Main Host Goes Away".

In most case you just get one of the vhosts instead of the main host
I would expect that if you commented out the

Include conf/extra/httpd-vhosts.conf

it would come back. This is do to the first vhost needing to be a duplicate of the main host. Since you did not include that file (which is where I figured the bad docroot is at). If you try it with that line commented out and it indeed does work, then that is where the problems stem.

I'd suggest first vhost being

<VirtualHost _default_:*>
DocumentRoot "C:/LocalhostWebPages"
</VirtualHost>

That is typically all you need.
Back to top
Mike-H



Joined: 29 Dec 2008
Posts: 16

PostPosted: Mon 12 Oct '09 19:01    Post subject: Reply with quote

Victory!

Yes, that worked. There are a few other lines already in that vhost definition in the vhost file. I left them intact and changed the document root as you suggested. Now the v-host sites work, as does the localhost. The vhost definition is started with this line:
<VirtualHost *:80> I don't know how that differs from what you posted, but I left it as it is and all seems ok for now.

Thank you for your help. Now I can finally get back to work!

Mike
Back to top


Reply to topic   Topic: Virtual Hosts work but not localhost View previous topic :: View next topic
Post new topic   Forum Index -> Apache