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: Appache VHost isnt going to my directory
Author
BedIntruder



Joined: 23 Oct 2010
Posts: 3

PostPosted: Sat 23 Oct '10 21:42    Post subject: Appache VHost isnt going to my directory Reply with quote

Im trying to set up a local vhost and every time I try to use a different .index in another directory, it keeps going back into the default directory (~Apache2.2\htdocs).

My httpd-vhosts.conf looks like this
Code:
NameVirtualHost 127.0.0.1:80

<VirtualHost 127.0.0.1:80>
    ServerAdmin webmaster@site1.local
    DocumentRoot "C:/vhost/www"
    ServerName site1.local
    ErrorLog "C:/vhost/www/error.log"
    CustomLog "C:/vhost/www/access.log" common

<Directory "C:/vhost/www">
    Order Deny,Allow
    Allow from all
</Directory>
</VirtualHost>

<VirtualHost 127.0.0.1:80>
    ServerAdmin webmaster@site2.local
    DocumentRoot "C:/vhost/site2.local/web"
    ServerName site2.local
    ErrorLog "C:/vhost/site2.local/Site/weberror.log"
    CustomLog "C:/vhost/site2.local/Site/access.log" common

<Directory "C:/vhost/site2.local/">
    Order allow,deny
    Allow from all
</Directory>
</VirtualHost>


My host file looks like this
127.0.0.1 site1.local
127.0.0.1 site2.local

From what I have gathered from this tutorial, you have to set the namevirtualhost back to localhost to get the default settings back.

If I put the site's files into the default directory as kind of like a subdirectory (~Apache2.2\htdocs\site1) I am able to locate the files without editing the httpd-vhost.conf file(http://site1.local/site1). I've also tried using *:80 as the NameVirtualHost. Is it supposed to be doing this?
I've also tried using this to allow access to the directory
Code:
<Directory "C:/vhost/www">
    Options ALL
    AllowOverride ALL
    Order allow,deny
    Allow from all
</Directory>
Back to top
BedIntruder



Joined: 23 Oct 2010
Posts: 3

PostPosted: Sat 23 Oct '10 22:31    Post subject: Reply with quote

Here's what is in the error log says:

[Sat Oct 23 16:00:00 2010] [notice] Apache/2.2.17 (Win32) configured -- resuming normal operations
[Sat Oct 23 16:00:00 2010] [notice] Server built: Oct 18 2010 01:58:12
[Sat Oct 23 16:00:00 2010] [notice] Parent: Created child process 3920
[Sat Oct 23 16:00:01 2010] [notice] Child 3920: Child process is running
[Sat Oct 23 16:00:01 2010] [notice] Child 3920: Acquired the start mutex.
[Sat Oct 23 16:00:01 2010] [notice] Child 3920: Starting 64 worker threads.
[Sat Oct 23 16:00:01 2010] [notice] Child 3920: Starting thread to listen on port 80.
[Sat Oct 23 16:00:12 2010] [error] [client 127.0.0.1] File does not exist: C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/favicon.ico
[Sat Oct 23 16:00:13 2010] [error] [client 127.0.0.1] File does not exist: C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/favicon.ico
[Sat Oct 23 16:00:14 2010] [error] [client 127.0.0.1] File does not exist: C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/favicon.ico
[Sat Oct 23 16:00:14 2010] [error] [client 127.0.0.1] File does not exist: C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/favicon.ico
[Sat Oct 23 16:00:15 2010] [error] [client 127.0.0.1] File does not exist: C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/favicon.ico
[Sat Oct 23 16:00:18 2010] [error] [client 127.0.0.1] File does not exist: C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/favicon.ico
[Sat Oct 23 16:00:19 2010] [error] [client 127.0.0.1] File does not exist: C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/favicon.ico
[Sat Oct 23 16:00:20 2010] [error] [client 127.0.0.1] File does not exist: C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/favicon.ico
[Sat Oct 23 16:00:20 2010] [error] [client 127.0.0.1] File does not exist: C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/favicon.ico
[Sat Oct 23 16:00:20 2010] [error] [client 127.0.0.1] File does not exist: C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/favicon.ico
[Sat Oct 23 16:00:23 2010] [notice] Parent: Received shutdown signal -- Shutting down the server.
[Sat Oct 23 16:00:23 2010] [notice] Child 3920: Exit event signaled. Child process is ending.
[Sat Oct 23 16:00:24 2010] [notice] Child 3920: Released the start mutex
[Sat Oct 23 16:00:28 2010] [notice] Child 3920: All worker threads have exited.
[Sat Oct 23 16:00:28 2010] [notice] Child 3920: Child process is exiting

So, I made a new icon and named it favicon.ico without any other errors, but it doesn't resolve the fact that it is still looking in that directory.
Back to top
glsmith
Moderator


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

PostPosted: Mon 25 Oct '10 23:00    Post subject: Reply with quote

Hi,

You will not find an error on this one, the fact that it does not work as expected is simply that the first vhost must be a duplicate of the main host in httpd.conf
see "Main host goes away" here: http://httpd.apache.org/docs/2.2/vhosts/name-based.html

Since it keeps going back to the program file location of htdocs, that must still be what the main host is in httpd.conf

So, first vhost after NameVirtualHosts 127.0.0.1:80
add

<VirtualHost 127.0.0.1:80>
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"
</VirtualHost>

Restart Apache and try after the change
Back to top
BedIntruder



Joined: 23 Oct 2010
Posts: 3

PostPosted: Wed 27 Oct '10 4:19    Post subject: Reply with quote

Quote:
<VirtualHost 127.0.0.1:80>
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"
</VirtualHost>


After trying this, the VHost still directs back to its original directory and not to the "C:/vhost/www" folder. I've tried uninstalling and reinstalling with no success.
I also tried doing this:
Code:

<VirtualHost 127.0.0.1:80>
    ServerAdmin webmaster@localhost
    DocumentRoot "C:\Program Files\Apache Software Foundation\Apache2.2\htdocs"
    ServerName localhost
    ErrorLog "C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\error"
    CustomLog "C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\custom" common
<Directory "C:\Program Files\Apache Software Foundation\Apache2.2\">
    Options ALL
    AllowOverride ALL
    Order allow,deny
    Allow from all
</Directory>
</VirtualHost>
Back to top
glsmith
Moderator


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

PostPosted: Thu 04 Nov '10 0:36    Post subject: Reply with quote

ARGH!! Sorry for delay! Cannot believe I did not see this sooner.

um .. if you are going to be using backslashes (\), better double them up.
Better yet, get really good and used to going into forward slash mode when dealing with Apache.

So
DocumentRoot "C:\Program Files\Apache Software Foundation\Apache2.2\htdocs" is incorrect.

What Apache is seeing is
DocumentRoot "c:rogram Filespache Software Foundationpache2.2tdocs"
\ is an escape character

This should show up in your error log about DocumentRoot not being found ... like

Warning: DocumentRoot [c:rogram Filespache Software Foundationpache2.2tdocs] does not exist

So either:
DocumentRoot "C:\\Program Files\\Apache Software Foundation\\Apache2.2\\htdocs"

or better
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs" using forward slashes.
Back to top


Reply to topic   Topic: Appache VHost isnt going to my directory View previous topic :: View next topic
Post new topic   Forum Index -> Apache