I've been looking for a efficient and secure way of enabling multi-site capabilities to codeigniter for a while.

These two(one & two) articles I found pretty interesting, but they don't seem to offer a scalable way of doing it. Of the two, John Dennis Pedrie's(link two) method seemed to be more thought out for our purposes.

However, say you have 100, 500, or 1000 separate sites, is this method still the best to go? Ie. would having 500 separate db config files in a folder and updating them with php be the best way to go?

Another method I can see being useful is a database of config options. Update the DB and you could have another site come online. However that would require storing all the database usernames and passwords in cleartext. Can't see that going over well.

Any answers, advice, tips, or interesting thoughts?

  • Why do you want to use a multitenancy approach rather than another approach? Jul 9, 2011 at 5:12
  • @Jeff It looks like it's the best approach for this particular web app and our team. We're small and updating and maintain multiple instances becomes cumbersome quickly. Are there other approaches that we might not know about? Jul 9, 2011 at 19:18

1 Answer 1


Unless the db schemas are going to be different between the different sites but the codebase is going to be the same, IMO it doesn't really make sense to partition on databases but not code if you're going to need to do it for more than say 10 sites.

I think the Django framework has an interesting approach where they define site ID's in a database table where each site is associated with a different domain name and associate content with site id's (https://docs.djangoproject.com/en/1.3/ref/contrib/sites/).

What you could do I guess is figure out what would be the same and what would be different between the different sites and attach a site identifier field to any tables that would have site-specific functionality. This assumes that all sites will be using the same servers. That way you only have to deal with one database which will make deploying updates easier. Adding another site would only require inserting a database record. Authentication and authorization logic would be a little more complicated since you would need to verify that the credentials and permissions are valid for a given site but that shouldn't be too difficult.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.