My Multi-Site solution

Steven

Hi Phil,


Looking good! However my hoster doesn't allow SSH access for security reasons. Is there another way to achieve this? With htaccess perhaps?

Regards,

Steven

psmith

I just wanted to share with everyone the solution I've put together which allows me to run multiple WB sites off of a single codebase. It requires SSH access.

1. Install your core copy of WB.  In my case, I installed it to /public_html/wb/
2. (Optional) Customize your core site settings as you want it to be setup as a starting point for all of your other sites.
3. Using phpMyAdmin or any other mySql administation tool, export a copy of your WB database.
4. Create a new database (and new database username) and import the core database you just exported.
5. Copy the following set of core files over to your new site directory. In my case, I copied these files over to /public_html/site/.


/media
/pages
/temp
/templates
/config.php
/index.php
/upgrade-scrpt.php
/.htaccess.txt


6. Update config.php in your new site directory to match the new database name and password you just created.
7. Using SSH, login to your server account and create symbolic links to the remaining directories:


/account
/admin
/framework
/include
/languages
/modules
/search


This is an example of the SSH command you would use for each directory while inside the /public_html/site directory :


ln -s ../wb/account ./account


8. Open config.php in the core installation folder and replace that code with the following:


$pattern = '/[\/]/';

$root = trim(dirname(__FILE__), '/wb');

$url = $_SERVER['PHP_SELF'];
$b = preg_split($pattern, $url);

require('/'.$root.'/'.$b[1].'/config.php');


And that's all there is to it.  I don't know if this is a great solution or not - maybe it's just quick and dirty - but it works!

It's important to note that this solution allows every site to have its own media, pages, and templates directory. Droplets and Modules are installed at a global level. SO, if you install a calendar module to the core site at the initial installation, every child site you make after that point will also have access to the SAME calendar module.

If you install a module to the core site AFTER you make a child site, each child site will have to have its database updated as well in order to make use of the new module.

This setup should theoretically work in any directory structure, as long as your symbolic links point to the right place.

I would appreciate any feedback from you if you have suggestions for improving this setup.

Regards,
Phil