Many applications

I need to have many yii apllications in this way:

www.domain.com / domain.com => app #1

*.domain.com => app #2 (e.g. company1.domain.com, company2.domain.com)

In the entry script (web/index.php) there are some logic that creates and configures these applications depending on the server name.

So, how to properly create and configure several applications (both web and console)? I use basic template.

Is there a detailed instruction somewhere?

You need to lookup multi-tenant and see how it works.

Is there more than theme (styling/css) differences between the various sub-domains? If no, then you should be ok with the entry script doing the selecting. If views, etc are also different then you may want to look at the advanced template and how they handle two different "websites" (frontend/backend)