Automatically creating subdomains

Hello everyone,
I have hired someone to program an ecommerce site for me. Part of how the site functions will be that a user will get their own subdomain. Is this acceptable here at Dreamhost? What info can I give him concerning the best way to do this utilizing a shared hosting account here?

After a general web search it appears to depend on how the server is configured or it can be done using a dns wildcard.

He’s an experienced php programmer but hasn’t tackled this particular problem yet.

It would be nice to save some of his paid development time by answering this one for him.

Ryan Shannon

That can’t be done automatically with shared hosting. You will need to use DreamHostPS and ask DreamHost support staff directly about adding both DNS and web server wildcards.

Otherwise with shared hosting subdomains must be added manually using the DreamHost Web Panel.

Customer since 2000 :cool:

Thanks for the quick reply.

I was afraid of that. My concern is that I have no idea if my site is going to be profitable or not.

Profitability would be reached with 2000 plus users. Each user would subscribe for 1 to 20 years. Memory usage should be below the minimum 150MB regardless of number of users so I’d should only have to pay the $15.00 a month. Due to the service being offered, bandwidth and disk space would be extremely low.

If it’s not profitable and I still have to host these user’s pages, I don’t want to have to continue to shell out money for a private server for up to 20 years. If I stopped accepting new users would the only way to avoid this be by manually creating the subdomains for the existing customers on my shared hosting plan and then manually transfering their content over?

Automatic sub-domain creation is stepping into the realms of reselling and as such I doubt DH have any intentions of implementing the feature in their API (at least not for shared). A workaround in your situation might be to have your developer setup sub-directory creation for user’s sites and manually create the sub-domains in Panel if they’re a necessity. It will be time consuming and there’s a chance there might be a limit hidden in the “unlimited” sub-domain number.

Maximum Cash Discount on any plan with MAXCASH

How To Install PHP.INI / ionCube on DreamHost

I contacted and received a reply from Max of their customer support team last night. He confirmed the need for having a private server to use a DNS wildcard.

There is no way that I could make my users wait for an unspecified time for them to want to purchase the service. I have no desire to create all the subdomains manually so I’ll just have to take the risk. If it isn’t successfull, I’ll continue to pay for a PS for the months that it will take transition back. Max said that they’ll move me back to shared hosting as long as my RAM usage doesn’t exceed the shared limits. He didn’t specifically say if they’ll assist with the subdomains or if they’ll stay created if I move back. However shared hosting is only a matter of a hundred some odd dollars per year so I don’t expect them to jump through flaming hoops for me.

He didn’t say anything about the possibility of an actual limit of the number of subdomains, but I didn’t specifically ask. I’ll ask these specific questions of them soon.

The only questions I still have for you guys are about the best way to achieve what I want. Upon registration a user will get one generated page using a few of their pictures and text info only. Is there any way that I can take advantage of this for site optimization, and/or subdomain linking? Can subdomains link to html files or do they only link to directories?


Your best bet would be to implement htaccess rewrites for each subdomain in order to redirect to another site’s html if that’s what you want to do.

On optimisation, if your engine is creating the user pages on the fly, have it create a static XHTML index.html for each user account and implement lighttpd (or similar) as your webserver rather than the ever-hungry Apache.

Depending on how you’re going about this, the engine account could easily be set up to have write privileges on the sub-domain directories, so if a user decides they would like a different look to their page (have your developer use a CSS repository) they can login to your main “engine” site and choose a new design - and any textual/picture adjustments they’d like to update - and the engine would then create and overwrite their index.html on submission, giving them an instant transformation. Extra carrot to wave at them, no extra cost to you.

Only your engine site would need PHP or PERL plus database access, the subs being completely static, which will both improve performance dramatically across the entire account and see your user’s pages delivered to browsers within milliseconds.

Maximum Cash Discount on any plan with MAXCASH

How To Install PHP.INI / ionCube on DreamHost


From my research and limited knowledge of web design theory this sounds exactly like what will work best.

As odd as it sounds, each of my users should have no desire to view each other’s pages. I’m not sure on the theory but I think that I need to implement htaccess to easily achieve the subdomain routing regardless.

This gives me some good info that I can compare to my developer’s ideas to find out how skilled he is. So far I have only interviewed him and am in the process of drawing slides for page layout and functionality. If I end up loosing confidence in him, does anyone have any suggestions for someone good who’s looking to make some money? I don’t think that I need someone brilliant, just sound and honest. On the converse side, I have enough knowledge to realize how detailed web development can be and I’m very detailed in my communication. Hopefully soliciting for help is acceptable here.

Thanks again for all of the replies,

The sub-domains only persist as such if they are specified in the zone for your domain and there are virtual host entries in the web server configuration. Thus if you get the nameserver or the web server to wildcard either one (ie, there is no record for a particular sub-domain) you’d have to manually add the sub-domains when moving to shared hosting. And I wouldn’t expect DreamHost staff to add 2,000 domains for you.

They work just like domains do. They link to resources.

Your mod_rewrite rules and CGI scripts can use the HTTP_HOST variable to determine what action to take based on what sub-domain was visited. Just keep in mind that nothing in your .htaccess files will cause your web hosting to accept unspecified or wildcard sub-domains - the web server is beyond that part of the process by the time it check your directories.

Customer since 2000 :cool:

Do you really require [color=#0000CC]name[/color] subbies as opposed to[color=#0000CC]name[/color]?

Seems that’s the only thing that’s slowing development at present, and on the face of it appears it could very well be a non-issue.

Maximum Cash Discount on any plan with MAXCASH

How To Install PHP.INI / ionCube on DreamHost

I do realy want for the uniqueness, marketing, and understandability of how the service works for people that aren’t familiar with it. I’m sorry for being so vague about the details. What I’m trying to do certainly isn’t patentable or copywriteable and my investors and I agree that the only way we can make this work is by being the first and the best.

With that said, I think that I know everything I need so I can start pumping cash into a developer.

Thanks again for all of the replies. I’ll still gladly listen to anyone that comes up with some pertinent information.

In that case, if you can convince DreamHost you know what you’re doing in respect to wildcard usage, they might come to the party with adding the function to your account. Get your game plan down before approaching them with the request again so that you can assuage any concerns that might be brought up.

Always worth a shot :wink:

Maximum Cash Discount on any plan with MAXCASH

How To Install PHP.INI / ionCube on DreamHost

Hi sXi,

I would like to know how to automatically create directories on my domain, such as

Can you please let me know how this is done? And is there a name for this process? (I’m not sure what to look for on Google!)

Thanks in advanced.


You have full control over your userspace, so any language can create directories.

Maximum Cash Discount on any plan with MAXCASH

How To Install PHP.INI / ionCube on DreamHost

OK great, do you know of any sites which have examples of this type of thing in php? What is this know as - automatic directory creation?

I wouldn’t think it’d be a “named” thing.

Get user’s name, place in a var (eg. $username), check that it’s available, create directory if so.

<?php mkdir($username,0755); ?>
Maximum Cash Discount on any plan with MAXCASH

How To Install PHP.INI / ionCube on DreamHost