Creating subdomains on the fly server template adjustment

4 posts / 0 new
Last post
#1 Wed, 03/09/2011 - 08:20
Paul_dH

Creating subdomains on the fly server template adjustment

Hi there,

I have installed Virtualmin a couple of days ago and I'm still figuring some things out. I got it running nicely and have made 2 virtual servers and everything works. Great piece of software and really easy to setup.

The only thing I would like to figure out is the "Subdomains on the fly" idea. My former webhost had the ability to just make a folder in public_html and then you had a subdomain like test.example.com I've searched google now a couple of days, and I have found some hints and tips but I am unsure how I can implement it in my setup. I know this can be done by editing the server template of Apache, but how exacly. The configfile looks like this:


ServerName ${DOM}
ServerAlias *.${DOM}

DocumentRoot ${HOME}/public_html/%1

ErrorLog /var/log/virtualmin/${DOM}_error_log
CustomLog /var/log/virtualmin/${DOM}_access_log combined
ScriptAlias /cgi-bin/ ${HOME}/cgi-bin/

DirectoryIndex index.html index.htm index.php index.php4 index.php5

Options -Indexes +IncludesNOEXEC +FollowSymLinks
allow from all
AllowOverride All

allow from all

How can I modify this that the subdomains are created on the fly? I do have a CNAME wildcard reccord in my DNS already.

Please help me out here :-) Thanks!

Wed, 03/09/2011 - 12:52
andreychek

Well, Sub-Domains are created "on-the-fly", but I assume you're seeking a way to have them put into the primary DocumentRoot (ie, underneath public_html).

Such a feature once did exist, and was removed as it caused a lot of confusion :-)

So, the preferred way to do that is to just create a new Sub-Server, and put your sub-domain website there. That would put it in /home/username/domains/sub.domain.tld/public_html.

However, if it's really important to you to be able to have a sub-domain in the public_html folder of your primary domain, you can go into System Settings -> Virtualmin Configuration -> Advanced Options. There, you'll see an option named "Allow creation of sub-domains". If you click that name, you'll get a help screen explaining why they're discouraged... if you're still interested in using them though, you can enable that feature from that screen :-)

-Eric

Thu, 03/10/2011 - 04:13
Paul_dH

I think that this is what I was searching for, I am indeed used to the fact that when I put a folder in my Public_html dir that that will be made a subdomain. To be more clear, like this:

public_html/www/wp-content/.....
public_html/forum/themes/...
public_html/test
public_html/images

Usually there has to be a .htaccess in the public_html folder that redirects the requests from example.com to www.example.com So the files in the public_html/www folder would be accessed.

So you mean that if I enable the mentioned setting, this would actually work. And if I enable it now, does the setting get applied to all of my existing virtual servers?

Just for curiosity, what was the confusion exactly? And I will have a search on sub-server , what these actually are :-)

Thanks for your reply btw Eric!

Thu, 03/10/2011 - 09:10
andreychek

So you mean that if I enable the mentioned setting, this would actually work. And if I enable it now, does the setting get applied to all of my existing virtual servers?

Yeah, if I remember correctly, I believe what happens if that you'll end up with a new Virtual Server type when you go into "create virtual server" -- it would be called a "sub-domain".

So, just create one of those, and you should be able to do what you're after :-)

-Eric

Topic locked