views:

294

answers:

2

I've developed a website with the idea of using a single codebase for multiple sites each with their own DB. Currently one is live, with many (up to 100) to follow.

My question is about the ideal, best-practice way of managing this kind of architecture (not necessarily the easiest or most realistic, but the ideal from which I can work back from).

For the codebase I have gone down the route of making the entire thing one install of codeigniter and associated code and all site related configuration is in a set of config files that pick up the host name and use that to define the site title, tracking code, css/js directories etc. This seems to be a good setup and I can see it working for a large number of sites of the same code.

For the databases, how would one manage multiple databases as the schema changes with development? Would you manually push changes to the databases as needed or use an automatic tool? There is a Rails like migrations plugin for Codeigniter here, that seems like it might be a good idea.

+1  A: 

If I understand you correctly you have multiple logical websites running off a single physical instance of the code, but each site has it's own database.

This is known as 'Multitenancy'; and you should be able to find plenty of architectural advice for this.

I haven't done a lot of this myself, and it's definitely non-trivial. It's a lot like security - you can't add it as an after-thought, if you want best practice you'll have to bake it into the design before you write a line of code.

It goes without saying that the code-base itself is only part of the overall solution: change management is going to be several orders of magnitude more difficult.

Sorry I can't offer more specific help.

Adrian K
+1  A: 

This article should show you exactly how to do it. It is really simple and works fine.

How to: Multi-site CodeIgniter Setup

Phil Sturgeon
Hi Phil - yes, this is it - I read this about a month ago when I was setting it up and I think that is the way to go for the code, was a really helpful post, thank you. I think my main difficulty will be getting the db management correct. I expect the database schema to change as development progresses and want to make sure I have a solid process to manage the updates.
Chris