WebsiteBaker Community Forum

General Community => Global WebsiteBaker 2.8.x discussion => Topic started by: psmith on March 02, 2010, 05:27:28 AM

Title: My Multi-Site solution
Post by: psmith on March 02, 2010, 05:27:28 AM
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/.

Code: [Select]
/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:

Code: [Select]
/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 :

Code: [Select]
ln -s ../wb/account ./account

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

Code: [Select]
$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
Title: Re: My Multi-Site solution
Post by: Steven on August 21, 2012, 02:37:12 PM
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