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: VirtualHost on Local machine (Apache 2.2.22)
Author
allenheresy



Joined: 19 Aug 2012
Posts: 4

PostPosted: Sun 19 Aug '12 7:50    Post subject: VirtualHost on Local machine (Apache 2.2.22) Reply with quote

Hello, I am having some issues setting up my virtualhost server. Each location will load on its own if I set it as the default; however no matter what address I use, it will only load the first "books-a-daisy.localhost"... eg: localhost/ loads books-a-daisy; kiosk.localhost/ loads books-a-daisy.

My .conf file is default except for these additions.

httpd.conf
Code:

ServerName 127.0.0.1:80
DocumentRoot "C://www/localhost"
#ErrorLog "C://www/logs/error.log"
#LogLevel warn

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

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

<VirtualHost localhost>
   ServerName books-a-daisy.localhost
   DocumentRoot "C://www/localhost/books-a-daisy"
</VirtualHost>

<VirtualHost localhost>
   ServerName heresytheory.localhost
   DocumentRoot "C://www/localhost/ht2"
</VirtualHost>

<VirtualHost localhost>
   ServerName rac.localhost
   DocumentRoot "C://www/localhost/rac"
</VirtualHost>

<VirtualHost localhost>
   ServerName kiosk.localhost
   DocumentRoot "C://www/localhost/kiosk"
</VirtualHost>


hosts
Code:

127.0.0.1   books-a-daisy.localhost
127.0.0.1   heresytheory.localhost
127.0.0.1   kiosk.localhost
127.0.0.1   rac.localhost


Any help would be greatly appreciated. Thanks!
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Mon 20 Aug '12 11:43    Post subject: Reply with quote

replace each
<VirtualHost localhost>
with
<VirtualHost *:80>
Back to top
allenheresy



Joined: 19 Aug 2012
Posts: 4

PostPosted: Thu 23 Aug '12 4:49    Post subject: Reply with quote

Thank you for your help. I have made those changes, and now everything now directs to the "books-a-daisy.localhost" directory... or the one I list first.

For testing, I removed this, which gives a 403.
Code:
<Directory "C://www/localhost">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
Back to top
glsmith
Moderator


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

PostPosted: Thu 23 Aug '12 5:24    Post subject: Reply with quote

Try making the first vhost with

<VirtualHost *:80>
DocumentRoot "C:/www/localhost"
</VirtualHost>

per this crazy difficult to understand note in the docs
http://httpd.apache.org/docs/2.2/vhosts/name-based.html

Quote:
Main host goes away

If you are adding virtual hosts to an existing web server, you must also create a <VirtualHost> block for the existing host. The ServerName and DocumentRoot included in this virtual host should be the same as the global ServerName and DocumentRoot. List this virtual host first in the configuration file so that it will act as the default host.


Also note that it's either a double backslash C:\\www\\somedir or single forward slash C:/www/somedir, not double forward slash C://www/somedir as you are showing here in many places. It seems Apache is luckily ignoring this but correct is correct.
Back to top
allenheresy



Joined: 19 Aug 2012
Posts: 4

PostPosted: Thu 23 Aug '12 5:50    Post subject: Reply with quote

Okay, I added the additional vhost as the first, and fixed all the backslash problems. Currently, everything directs to /localhost (the first one in the list)

This is the updated file. Thanks again for the help, this is the first time I've had to set up anything vhost related.
Code:
<IfModule dir_module>
    DirectoryIndex index.html index.htm
</IfModule>

ServerName 127.0.0.1:80
DocumentRoot "C:\\www\localhost"
#ErrorLog "C:\\www\logs\error.log"
#LogLevel warn

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

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

<VirtualHost *:80>
   ServerName 127.0.0.1:80
   DocumentRoot "C:\\www\localhost"
</VirtualHost>

<VirtualHost *:80>
   ServerName books-a-daisy.localhost
   DocumentRoot "C:\\www\localhost\books-a-daisy"
</VirtualHost>

<VirtualHost *:80>
   ServerName heresytheory.localhost
   DocumentRoot "C:\\www\localhost\ht2"
</VirtualHost>

<VirtualHost *:80>
   ServerName rac.localhost
   DocumentRoot "C:\\www\localhost\rac"
</VirtualHost>

<VirtualHost *:80>
   ServerName kiosk.localhost
   DocumentRoot "C:\\www\localhost\kiosk"
</VirtualHost>
Back to top
glsmith
Moderator


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

PostPosted: Thu 23 Aug '12 8:12    Post subject: Reply with quote

ARGH! ... Tell you what ... do not use backslahes period and never, ever double up forward slash [1].
So let's just stick with this:

C:/www/localhost
C:/www/localhost/books-a-daisy
C:/www/localhost/ht2
C:/www/localhost/rac
C:/www/localhost/kiosk

C:/www/logs/error.log


I was assuming that this portion;

ServerName 127.0.0.1:80
DocumentRoot "C:\\www\localhost"
#ErrorLog "C:\\www\logs\error.log"
#LogLevel warn

was the main stuff (global) in the httpd.conf file.

If that is the case, then per that note in the docs, a minimal version of it needs to be first vhost. So, if my assumption was right, then it must be this odd slashing thing you have going on that is mucking up the works.

[1] There is only one case where you would double up the forward slash, but this is not it and to not add confusion I'm not telling you what it is Very Happy
Back to top
allenheresy



Joined: 19 Aug 2012
Posts: 4

PostPosted: Fri 31 Aug '12 4:23    Post subject: Reply with quote

Well, thank you for your help. Things did not quite work out for me sadly. I'm thinking about throwing apache out as local, and building a networked server instead. That will probably make things work much easier.

Thanks again!!!
Back to top


Reply to topic   Topic: VirtualHost on Local machine (Apache 2.2.22) View previous topic :: View next topic
Post new topic   Forum Index -> Apache