Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Sun May 24, 2009 5:11 am 
Offline
Newbie

Joined: Thu May 21, 2009 12:59 pm
Posts: 3
Hi everyone, please excuse the simple question but i've been driving myself nuts trying to find some form of example of using simple-vhost for multiple domains without having to set up each one myself.

I've used the following

Quote:
simple-vhost.server-root = "/var/www/"
simple-vhost.default-host = "localhost"
simple-vhost.document-root = "/www/"


Which works fine for http://domain1.com and http://domain2.com but trying to go to http://www.domain1.com or http://www.domain2.com does not work :( I'm guessing I'm missing something really simple but can't seem to find any examples at all.

Any help would be great, thanks in advance


Top
   
 Post subject:
PostPosted: Sun May 24, 2009 8:29 am 
Offline
Senior Member
User avatar

Joined: Tue Apr 13, 2004 6:54 pm
Posts: 833
with lighttpd simply vhosts, you create a subdirectory for each virtual host you want.
eg
Code:
mkdir /var/www/domain1.com
mkdir /var/www/domain2.com


Now "www.domain1.com" is _different_ to "domain1.com".

So what I do is symlink them
Code:
cd /var/www
ln -s domain1.com www.domain1.com


Now requests for "domain1.com" and "www.domain1.com" are both served from the same tree.

_________________
Rgds
Stephen
(Linux user since kernel version 0.11)


Top
   
 Post subject:
PostPosted: Sun May 24, 2009 8:45 am 
Offline
Junior Member

Joined: Tue Feb 03, 2004 2:37 pm
Posts: 26
I don't use lighttpd but I did try to set it up last night.

From what I've read the vhost looks in the directory name based on those three settings.

So for domain1.com would be /var/www/domain1.com/www/ and www.domain1.com would be /var/www/www.domain1.com/www

Is it as easy as putting a sym link for www.domain1.com into that directory?


Top
   
 Post subject:
PostPosted: Sun May 24, 2009 9:34 am 
Offline
Senior Member
User avatar

Joined: Sat Aug 30, 2008 1:55 pm
Posts: 1739
Location: Rochester, New York
Two ways to do it:

1) The symlink method. This works just fine.

2) The redirect method. I've become cantankerous and determined that http://www.domain.com/ is redundant, so I've now standardized upon http://domain.com/. This also means /var/www is much neater because there's not a lot of symlinks all around.

Anyway, here's the config I'm using for that:

Code:
$HTTP["host"] !~ "^(www\..*)$" {
        ## The document root of a virtual host isdocument-root =
        ##   simple-vhost.server-root + $HTTP["host"] + simple-vhost.document-root
        simple-vhost.server-root         = "/var/www"
        simple-vhost.document-root       = "/html/"

        ## the default host if no host is sent
        simple-vhost.default-host        = "default-fall-through.hoopycat.com"
}

# www.*
$HTTP["host"] =~ "^www\.(.*)" { url.redirect = ( "^/(.*)" => "http://%1/$1" ) }


Doing it the other way -- redirecting from http://domain.com/ to http://www.domain.com/ -- is left as an exercise for the reader.


Top
   
 Post subject:
PostPosted: Sun May 24, 2009 11:35 am 
Offline
Newbie

Joined: Thu May 21, 2009 12:59 pm
Posts: 3
hoopycat - thank you for your post, gave me a good idea for what i'm looking for, although i will prefer not to use the URL redirect on the www. but you have give me a good example and i should be able to take it from here :)


Top
   
 Post subject:
PostPosted: Mon May 25, 2009 4:36 pm 
Offline
Newbie

Joined: Thu May 21, 2009 12:59 pm
Posts: 3
I'm slightly confused and think im trying to create too complex a setup for my vhosts.

I thought it would be possible to setup something using simple-vhost that could capture the domain and any possible sub-domains for any pointed to my linode.

I've been trying to find other examples after the one hoopycat posted but failed.

Can you use regex with simple-vhost?


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group