Frankie T Posted October 22, 2010 Share Posted October 22, 2010 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! Quote Link to comment https://forums.phpfreaks.com/topic/216536-isolated-virtual-accounts/ Share on other sites More sharing options...
trq Posted October 22, 2010 Share Posted October 22, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/216536-isolated-virtual-accounts/#findComment-1125156 Share on other sites More sharing options...
Frankie T Posted October 23, 2010 Author Share Posted October 23, 2010 Thanks, Thorpe. Anyone else? I'm looking for something a bit more specific. Where should I be looking for help on a project like this? Any books/websites I could leverage for reference? Quote Link to comment https://forums.phpfreaks.com/topic/216536-isolated-virtual-accounts/#findComment-1125440 Share on other sites More sharing options...
trq Posted October 23, 2010 Share Posted October 23, 2010 I'm not sure you'll find much specific information around. I know I didn't. It should just be part of your design, to keep each client specific piece of code separate from the core of the system. Quote Link to comment https://forums.phpfreaks.com/topic/216536-isolated-virtual-accounts/#findComment-1125442 Share on other sites More sharing options...
Frankie T Posted October 23, 2010 Author Share Posted October 23, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/216536-isolated-virtual-accounts/#findComment-1125445 Share on other sites More sharing options...
trq Posted October 23, 2010 Share Posted October 23, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/216536-isolated-virtual-accounts/#findComment-1125451 Share on other sites More sharing options...
Frankie T Posted October 23, 2010 Author Share Posted October 23, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/216536-isolated-virtual-accounts/#findComment-1125454 Share on other sites More sharing options...
trq Posted October 23, 2010 Share Posted October 23, 2010 So, that is what is different. So in other words, that is the part that goes within the client own virtual host. The rest of the application goes in a separate location outside of anyones virtual host. Quote Link to comment https://forums.phpfreaks.com/topic/216536-isolated-virtual-accounts/#findComment-1125458 Share on other sites More sharing options...
Frankie T Posted October 23, 2010 Author Share Posted October 23, 2010 I imagine that the logos would all be in a single 'logos' folder. I'd then store the URL of the logo in the database and pull it as needed. Quote Link to comment https://forums.phpfreaks.com/topic/216536-isolated-virtual-accounts/#findComment-1125459 Share on other sites More sharing options...
trq Posted October 23, 2010 Share Posted October 23, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/216536-isolated-virtual-accounts/#findComment-1125461 Share on other sites More sharing options...
Frankie T Posted October 23, 2010 Author Share Posted October 23, 2010 Bingo. Sorry for the confusion. That's exactly what I'm looking for. Would I need a dedicated hosting account to do what you've described? Quote Link to comment https://forums.phpfreaks.com/topic/216536-isolated-virtual-accounts/#findComment-1125462 Share on other sites More sharing options...
trq Posted October 23, 2010 Share Posted October 23, 2010 Would I need a dedicated hosting account to do what you've described? If you just want to use simple sub domains, no. You should be able to do that easily enough within your .htaccess file. Quote Link to comment https://forums.phpfreaks.com/topic/216536-isolated-virtual-accounts/#findComment-1125465 Share on other sites More sharing options...
Frankie T Posted October 23, 2010 Author Share Posted October 23, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/216536-isolated-virtual-accounts/#findComment-1125466 Share on other sites More sharing options...
trq Posted October 23, 2010 Share Posted October 23, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/216536-isolated-virtual-accounts/#findComment-1125470 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.