tags:

views:

72

answers:

1

Not quite sure how to phrase this, but will do my best.

I have an application (written in PHP) that I want to install somewhere like this:

/app/build/1.0/

Now, I want to be able to set up subdomains, something like this:

http://sub1.mydomain.com
http://sub2.mydomain.com
etc ..

First, I want to put the least # files as possible in the subdomains (I am thinking just a config file), and point to the build folder for all php files.

However, in the case where the subdomain has some sort of customization, I would like to be able to actually place the customized file in the subdomain, and then the app would use that (in other words, app first looks for local file, if it exists use it, otherwise, use the default build folder files).

Last, if I release 1.1, I should simply be able to re-point the subdomains to the 1.1 folder.

I have a basic understanding of this and how I might achieve it, but what I am looking for is alternative ideas, or gotchas I may face (or anything else I may not have considered like scalability issues I may not see yet, or other things I may not be able to do if I go this route).

Bottom line question: Is this a good or bad idea, and why?

+2  A: 

I'm assuming that the config file in each subdomain means there will be config differences for every site, so that you can't combine all of the uncustomized sites into one folder and simply have the subdomains point to it (in DNS).

I have set up sites such that the subdomains would have a single index.php file. The index.php file would define a bunch of config options and then call something equivalent to startApp(); Each site would have its include path set to include the application files. That can be done in the apache config or in the index.php file.

If you want to customize a site, then you would change the include path to point to the customized code, which you could keep in that sites folder if you want.

Honestly, I think the harder problem will be keeping all the customizations documented and updated. That's a totally different problem though.

Scott Saunders
interesting idea though Scott. any way for PHP to know the subdomain name? if so, I can use that to build a prefix for the DB.
OneNerd
$_SERVER['SERVER_NAME'] should give it to you. See: http://us3.php.net/manual/en/reserved.variables.server.php
Scott Saunders
cool. I will give it a try - if it works, ill mark your answer as accepted -- gimme a week or so to put thru paces though. Thanks :)
OneNerd
Sure thing. Good luck!
Scott Saunders
Any luck implementing this?
Scott Saunders
Scott - not 100% done yet, but this concept has certainly taken me almost there, so marking yours answer as accepted - thanks again!
OneNerd