lighttpd - simpe-vhost & evhost - lost
Please, wait! Don't scream - I used search! I used google…I followed ALL possible documentation.
But lighttpd still doesn't perform as it should regarding vhosts.
I'm not sure what I do wrong. If I even do anything wrong?
So, I have:
Ubuntu 10.04
lighttpd
I have a domain linked to my linode. i.e. domain.com
I want to organize a repository for ALL web content at:
/var/www/
where I want to have a folder per each domain:
/var/www/domain.com/
and in case if a domain uses SUB domain, use the folder INSIDE the domain folder:
That kind of infrastructure was on my shared hosting and I want to maintain it.
But I'm lost.. I can't achieve it with simple-vhost mod. And with evhost - … I'm drowning in conditionals…
And also, I have a naive question. Do I need to add any dns records for sub domains I'm going to use? (A rec?)
p.s. I'm sorry peopl, you are my last resort!!!)
8 Replies
@Yuraa:
in case if a domain uses SUB domain, use the folder INSIDE the domain folder:
http://sub.domain.com/ –-> /var/www/domain.com/sub/That kind of infrastructure was on my shared hosting and I want to maintain it.
I don't think lighttpd supports that. The setup you're describing is a hack popularized by cPanel, and AFAIK it's not supported by any web server natively. From the point of view of a web server, sub.domain.com is a completely different domain from domain.com.
Here's a workaround:
mkdir /var/www/sub.domain.com
ln -s /var/www/sub.domain.com /var/www/domain.com/sub
@Yuraa:
And also, I have a naive question. Do I need to add any dns records for sub domains I'm going to use? (A rec?)
Yes, you must add an A record for each and every sub domain you want to use. There are a lot of things that cPanel does automatically which you must do manually if you don't have cPanel.
> ````
ln -s /var/www/sub.domain.com /var/www/domain.com/sub
````
well - that's pretty "straight forward"
so if not this linking - it can't be achieved with lighttpd settings?
> Yes, you must add an A record for each and every sub domain you want to use. There are a lot of things that cPanel does automatically which you must do manually if you don't have cPanel.
Thanks:) Well, I "knew" i should….hoped for some sci-fi scenario..that may be not:)
What i did is this:
folders:
/var/www/domain.com
/var/www/domain.com/test
then
vi /etc/lighttpd/lighttpd.conf
enabled mod_evhost
and set the path pattern to look like:
evhost.path-pattern = "/var/www/%0/%3/"
and it works.
BUT
and I need it to be --> /var/www/domain.com/
so here may be ****I'll use linking folders ***** - though I for some reason don't like it.
Further if I'll be able to get through conditional things - i'll probably will be setting conf file per domain. much nicer and easier to manage i think.
** Stupid idea:)) recursive links? o.O
UPD: Meanwhile with mod_redirect made all request going to domain.com to be redirected to
Why not something like this:
/var/www/example.com/www <– main domain
/var/www/example.com/sub-domain <-- sub-domain
Are you one of those "no-www" guys?
@waldo:
Why do you need your sub-domain to be in a sub-directory of your main domain's directory?
Why not something like this:
/var/www/example.com/www <– main domain
/var/www/example.com/sub-domain <-- sub-domain
Are you one of those "no-www" guys?
but what's the difference between your suggestion and mine?
no - i'm fine with www and without www.
If you can give me a bit more insight on how adding "www" will help - i'd really appreciate that!
I don't want people to be able to see the sub-domain content at
@waldo:
I don't know about "helping" or not. It's how I structure my sites. Call "www" what ever you want, "main", what ever. It keeps my sub-domain files completely out of my main site's files.
I don't want people to be able to see the sub-domain content at
www.example.com/sub-domain and I don't want to deal with redirects or rewrite rules to prevent that.
didn't really got the purpose of your reply then…
well, the only reasonable thing I can say is ….. Ok:)
> I don't want people to be able to see the sub-domain content at
Why is that "bad"? I mean - to know that
Well - i agree - there might be some sort of a risk (messed up with index and so on and people can browse the root) but in my case I don't care about it:)
> and I don't want to deal with redirects or rewrite rules to prevent that.
Neither do I. But i'm curious how it can be possible to achieve such configuration with the most easiest solution.
@Yuraa:
set the path pattern to look like:
evhost.path-pattern = "/var/www/%0/%3/"
and it works.
Hmm, evhost is smarter than I guessed. There must have been a lot of requests for the subdomain-is-subdirectory hack.
At any rate, it's a good idea to keep your subdomain files outside of the main website's document root. It can have unpleasant consequences, such as hurting your Google ranking. (You can do redirects, but it can be annoying if you have to do it ad hoc all the time. Especially since lighttpd doesn't support .htaccess.)
cPanel uses this hack because it's easier for them to manage and easier for newbies to understand. But if you're competent enough to run your own VPS, you should do it the right way ™.