OneNerd
OneNerd

Reputation: 6552

Strategy for subdomain applications using PHP

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?

Upvotes: 0

Views: 173

Answers (1)

Scott Saunders
Scott Saunders

Reputation: 30414

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.

Upvotes: 2

Related Questions