I have created a custom, specialized CMS with a number of clients on it, each with their own domain name, website, admin area and database, but all residing on the same server.
Whenever I get a new client, I simply copy all of the code over, change 3 lines in a config file, and then all of their styles/data is taken out of the database or from uploads they post to the server from their own admin area.
Sounds great so far right?
Well when I recently decided to update all of the clients sites, this became a major pain. Obviously i had to change the code on each install. For a major update this is fine, but for frequent tweaks or the like, duplicating the effort of uploading becomes very annoying....I hope to someday have dozens or hundreds of clients, so the code will eventually have to be centralized so that changing it in one place updates it everywhere...how does one do that?
How about something that uses the same code, but each has own mysql.
Like, http://mycms.com/myuser/ brings the prefix myuser_ to the tables, thus, allowing 1 src structure, and multiple site. You will need .htaccess though
Personally, I have a client table on the database that holds the current version number of the code that they're running. When a user logs in, it sets a cookie called CodeVersion indicating the code version for that client (e.g. "v5-09-00"). In the Apache .htaccess, I have:
and within the local hosts file, I have:
which handles local redirection within Apache to an entry in vhosts
The vhosts file sets the environment for each version of the code:
Within each set of directories, I can have symbolic links pointing to common code, and actual php/ini files for client-specific code or configuration.
I'd split into the
library
(your working code) and theconfig
(the three lines for each user, probably database connections and the like).Split the
library
out to a universal location eg/home/library
(in *nix) and allow read attribute to the other user accounts.Now for each site there's a
config
file which first includes thelibrary
and second sets the site-specific config. Updating thelibrary
updates all versions. A word of caution though - you'll want to have some unit tests in place such that an update of thelibrary
doesn't break anyone of the single sites.eg
config
: (one per site)If your library of code is also used to render the content (index.php etc) then you have two options: (1) create
symlinks
between each site's web folders and thelibrary
source, or (2) separate your code into core functionality and rendering code.A symlink creates a system link between two points on the drive (it's like a pointer). A properly created link allows you to access a folder by a different name so you can create
/home/user1/library
,/home/user2/library
/home/user3/library
, and they all point and contain the content of/home/library
(they're not copies of the data).I'd be included to go with #2 although it'll take more work up front. Your
library
does the work, but the site rendering is performed by the the second piece of code which is supplied on a per-site bases (likely including the afore mentionedconfig
), this allows more flexibility on a site by site basis (even if you don't foresee yourself needing this yet). As a side effect you're on the way to a multi-tiered application.