Jump to content

Isolated Virtual Accounts


Frankie T

Recommended Posts

Hey thar,

 

New to the forums. I have a simple question with what I imagine to be a fairly complex answer.

 

I'm creating a web application (software as a service, etc.) that will be used by many companies. I'd like these companies to be isolated from each other on the interface level, with each account living virtually in its own subdomain, but united in one database, sharing the same core platform that I'd only have to change in one place to affect all users, like WordPress.com for example.

 

What kind of techniques might I use to achieve this?

 

Thanks!

Link to comment
Share on other sites

Its not an uncommon case. I run a hosted CMS service that has over 1100 clients all hosted within there own virtual host, all using the same CMS core, there own databases and there own configurations.

 

Its quite easy if your application is itself built on a well designed framework. You just need to split the core code and the client specific code apart.

Link to comment
Share on other sites

Maybe I'm missing something, but there really isn't any client-specific code in what I'm doing (I think). Every client will be using the same platform, the same code.

 

Do I simply create the illusion of separation with SQL queries that get results only where client = theCorrectOne? If that's so, then how do I create subdomains dynamically without creating an actual folder for them?

 

 

Link to comment
Share on other sites

Maybe I'm missing something, but there really isn't any client-specific code in what I'm doing (I think). Every client will be using the same platform, the same code.

 

That might be the case, but there has to be at least something different about each client. Each client in my system basically only varies by loading there own configuration file.

 

My application itself is kept within /usr/local/<myappname>, the framework it uses is within /usr/share/php/<theframework>, then each client is within /var/www/sites/<client name>/htdocs

 

Each client has an index.php file and a configuration file. They also have there own templates (all loaded from the config file) etc etc

 

If your client are all going to be using the EXACT same system (design and all), you might not need anything like this. You might be able to get enough information by simply looking at the hostname and determining what client data you need to then serv based on that.

 

My clients all have there own databases, but you could use one if you like, it just means that every record would need a client id attached to it or something.

 

As for virtual hosting, that's up to Apache. See....

 

http://httpd.apache.org/docs/2.0/vhosts/mass.html

Link to comment
Share on other sites

Fair enough.

 

Yes, every entry is being stored in a single database, and they do all have a client ID column. The layout for every client will be the same, with the exception of the logo, all of which will be stored in a single folder and renamed dynamically so that my application can easily pull them out.

 

Does that sound like a reasonable approach?

Link to comment
Share on other sites

So, your not trying to separate the application at all? Just have it served up via many different sub domains?

 

You really don't need to do anything at all special. I think I've completely misinterpreted your original question.

 

You can make any number of apache virtual hosts all share the same document root. This is basically what your wanting to do.

 

You can then have some logic in your application somewhere that determines what client data (including this logo) to use based on the hostname. Done.

Link to comment
Share on other sites

Any place you could refer me to for more info? I've seen a lot of that all over the interwebs, but many great programmers are horrible communicators, and I can't seem to understand what specifically needs to be done based on their limited grasp on English.

 

Thanks again.

Link to comment
Share on other sites

Actually, you would only need to use rewritting if you wanted each sub domain to have its own document root. You don't, so you likely only need to setup wildcards within your DNS setup.

 

You'll need to take a look on the docs for your DNS provider for instruction on how to do so through there control panel.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.