Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Tue Feb 08, 2011 3:29 pm 
Offline
Senior Newbie

Joined: Tue Feb 08, 2011 3:19 pm
Posts: 5
Hello All!

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:

http://sub.domain.com/ ---> /var/www/domain.com/sub/

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!!!)


Top
   
PostPosted: Tue Feb 08, 2011 5:00 pm 
Offline
Senior Member

Joined: Fri May 02, 2008 8:44 pm
Posts: 1121
Yuraa wrote:
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:
Code:
mkdir /var/www/sub.domain.com
ln -s /var/www/sub.domain.com /var/www/domain.com/sub


Yuraa wrote:
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.


Top
   
 Post subject:
PostPosted: Tue Feb 08, 2011 5:12 pm 
Offline
Senior Newbie

Joined: Tue Feb 08, 2011 3:19 pm
Posts: 5
Quote:
Code:
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?

Quote:
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:)


Top
   
 Post subject:
PostPosted: Tue Feb 08, 2011 6:06 pm 
Offline
Senior Newbie

Joined: Tue Feb 08, 2011 3:19 pm
Posts: 5
Solved it almost with evhost:)

What i did is this:

folders:

Code:
/var/www/domain.com
/var/www/domain.com/test


then

Code:
vi /etc/lighttpd/lighttpd.conf


enabled mod_evhost

and set the path pattern to look like:

Code:
evhost.path-pattern = "/var/www/%0/%3/"


and it works.

http://domain.com/ --> /var/www/domain.com/
http://test.domain.com/ --> /var/www/domain.com/test/

BUT

http://www.domain.com/ --> /var/www/domain.com/www/
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 :))) Need another way......

UPD: Meanwhile with mod_redirect made all request going to domain.com to be redirected to www.domain.com. works - but seems to be a bit of a stone age:(


Last edited by Yuraa on Tue Feb 08, 2011 6:24 pm, edited 1 time in total.

Top
   
 Post subject:
PostPosted: Tue Feb 08, 2011 6:19 pm 
Offline
Senior Member

Joined: Thu May 21, 2009 3:19 am
Posts: 336
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?


Top
   
 Post subject:
PostPosted: Tue Feb 08, 2011 6:23 pm 
Offline
Senior Newbie

Joined: Tue Feb 08, 2011 3:19 pm
Posts: 5
waldo wrote:
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!


Top
   
 Post subject:
PostPosted: Tue Feb 08, 2011 6:40 pm 
Offline
Senior Member

Joined: Thu May 21, 2009 3:19 am
Posts: 336
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.


Top
   
 Post subject:
PostPosted: Tue Feb 08, 2011 6:49 pm 
Offline
Senior Newbie

Joined: Tue Feb 08, 2011 3:19 pm
Posts: 5
waldo wrote:
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:)

Quote:
I don't want people to be able to see the sub-domain content at www.example.com/sub-domain


Why is that "bad"? I mean - to know that www.domain.com/folder/ is exists they need to....well..know it. I understand if they can "guess" or browse your root without index file and see all sub-domains.

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:)

Quote:
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.


Top
   
 Post subject:
PostPosted: Tue Feb 08, 2011 6:53 pm 
Offline
Senior Member

Joined: Fri May 02, 2008 8:44 pm
Posts: 1121
Yuraa wrote:
set the path pattern to look like:

Code:
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 (tm).


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


Who is online

Users browsing this forum: No registered users and 2 guests


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