multisite with single install

Multisite with single install, a forum discussion on Jojo CMS. Join us for more discussions on Multisite with single install on our Installation forum.

Back to Forum Index : Back to Installation   RSS
dennyhalim

10 May 2009
Posts: 44

what do you think if i hack jojo config like this:
http://me.mywebsight.ws/2006/08/11/host-multiple-wp-sites-on-one-installation/

that will allow i have only one install, one db to host multiple domain.

i'm planning using it for few small traffic web with only few pages company profile.
so it wont slow down any database...

or...
any better ways doing this?

maybe an installer?

i need something that can expedite jojocms installs without i need to login to cpanel/phpmyadmin, create database, user, etc....

something i can teach a non-technical web designer to do without give him/her login to cpanel/phpmyadmin/ftp/etc...

somehow so that all i need to do is just point the domain to the correct ip and can get jojocms installed without entering database details.

any idea?

tia.
tnx for great free jojocms
Harvey

Core Developer

Harvey

12 May 2009
Posts: 327

This sort of thing is possible, but will require some custom scripting. I created a script a while back for a previous version which integrated the Jojo install process into the client's own control panel. They added a customer via their system and a Jojo folder was created for them, index.php and .htaccess were put in place, database created, Jojo config file created, the virtualhost created, Apache restarted, etc.

I can't share the code for this sorry, it's not mine to share and it was *very* specific to the server that it was running on (not cpanel).

If you were interested in creating your own script, I could give you a list of things that need to be done.

The Jojo side of things is pretty easy - you need to get your script to create the Jojo config file, then open www.domain.com/setup/
The hard part is scripting the creation of everything else (database, database user, virtual host, folders + permissions etc)
mikec

Lead Developer

mikec

12 May 2009
Posts: 67

A similar scenario would be to run all the sites out of the same database using table prefixes using a config like below.


<?php

/* Database Connection */
define('_DBHOST', 'localhost');
define('_DBUSER', 'dbuser');
define('_DBPASS', 'dbpass');
define('_DBNAME', 'database');

/* Directory locations */
define('_BASEDIR', '/home/jojo/trunk/');
define('_WEBDIR', dirname(__FILE__));

/* Debug Options - not recommended for production installations */
define('_DEBUG', true);

/* Master password */
define('_MASTERPASS', 'passwd');

/* Admin root */
define('_ADMIN', 'admin');

$table_prefix = ereg_replace('^(www\.)', '', $_SERVER['HTTP_HOST']);
$table_prefix = ereg_replace('\.', '', $table_prefix);
define('_TBLPREFIX', $table_prefix . '_');
define('_MYSITEDIR', '/home/sites/' . $table_prefix);


Point all the virtual hosts at the same folder with index.php, .htaccess, and this config.php.

To create a new site create the '/home/sites/' . $table_prefix folder for jojo to put its downloads, cache etc. and then hit http://new.site.example.com/setup and jojo with create all the tables and other files that it needs.

If you want to have all the sites share a common themes or plugins folder then set


define('_THEMEDIR', '/home/sites/commonthemes');
define('_PLUGINDIR', 'home/sites/plugins');


I've not actually tried this so YMMV but the theory is good :-) Replace folder names as appropriate and would like to know how it goes.

- Mike
dennyhalim

12 May 2009
Posts: 44

just like what i had in mind.

i change few bits:

//..... only changed line .....//

$table_prefix1 = ereg_replace('^(www\.)', '', $_SERVER['HTTP_HOST']);
$table_prefix = ereg_replace('\.', '', $table_prefix1);
define('_TBLPREFIX', $table_prefix . '_');
define('_MYSITEDIR', '/home/sites/' . $table_prefix1);
// so that the folders looks better in my eyes...//


then run http://website/setup
and got this:

Executing plugin code

Jojo will now scan through each plugin and look for changes that have been made to the database structure. If changes need to be made, the option to "fix" will be available, and in most cases we recommend you do this.
Jojo_Plugin_Jojo_Article: Regenerating HTML cache for Articles
Jojo_Plugin_Jojo_Tags: Regenerating tags for articles
SHOW COLUMNS FROM `polarisnozonenetcom_polarisnozonenetcom_article` Table 'polaris_jojosite.polarisnozonenetcom_polarisnozonenetcom_article' doesn't existarray(3) { [0]=> array(6) { ["file"]=> string(68) "/hsphere/local/home/polaris/master/jojocms-1.0rc1/includes/setup.php" ["line"]=> int(315) ["function"]=> string(11) "selectQuery" ["class"]=> string(4) "Jojo" ["type"]=> string(2) "::" ["args"]=> array(1) { [0]=> &string(47) "SHOW COLUMNS FROM {polarisnozonenetcom_article}" } } [1]=> array(4) { ["file"]=> string(67) "/hsphere/local/home/polaris/master/jojocms-1.0rc1/includes/jojo.php" ["line"]=> int(48) ["args"]=> array(1) { [0]=> string(68) "/hsphere/local/home/polaris/master/jojocms-1.0rc1/includes/setup.php" } ["function"]=> string(7) "require" } [2]=> array(4) { ["file"]=> string(59) "/hsphere/local/home/polaris/polaris.nozonenet.com/index.php" ["line"]=> int(36) ["args"]=> array(1) { [0]=> string(67) "/hsphere/local/home/polaris/master/jojocms-1.0rc1/includes/jojo.php" } ["function"]=> string(12) "require_once" } }


and when opening http://website i got this:

Redirect Loop













Firefox has detected that the server is redirecting the request for this address in a way that will never complete.







The browser has stopped trying to retrieve the requested item. The site is redirecting the request in a way that will never complete.

* Have you disabled or blocked cookies required by this site?
* NOTE: If accepting the site's cookies does not resolve the problem, it is likely a server configuration issue and not your computer.


nb.
a normal installs works flawlessly with same folder structures.
tnx for great free jojocms
dennyhalim

12 May 2009
Posts: 44

wonder why the tableprefix appended twice?
tnx for great free jojocms
mikec

Lead Developer

mikec

13 May 2009
Posts: 67

I think there might be a bug in includes/setup.php

Try adding
$tblname = str_replace(_TBLPREFIX, '', $tblname);
at line 297
dennyhalim

13 May 2009
Posts: 44

first site setup ok.

second site setup give me this:

SHOW COLUMNS FROM `b2indonet_polarisnozonenetcom_article` Table 'polaris_jojosite.b2indonet_polarisnozonenetcom_article' doesn't existarray(3) { [0]=> array(6) { ["file"]=> string(68) "/hsphere/local/home/polaris/master/jojocms-1.0rc1/includes/setup.php" ["line"]=> int(316) ["function"]=> string(11) "selectQuery" ["class"]=> string(4) "Jojo" ["type"]=> string(2) "::" ["args"]=> array(1) { [0]=> &string(47) "SHOW COLUMNS FROM {polarisnozonenetcom_article}" } } [1]=> array(4) { ["file"]=> string(67) "/hsphere/local/home/polaris/master/jojocms-1.0rc1/includes/jojo.php" ["line"]=> int(48) ["args"]=> array(1) { [0]=> string(68) "/hsphere/local/home/polaris/master/jojocms-1.0rc1/includes/setup.php" } ["function"]=> string(7) "require" } [2]=> array(4) { ["file"]=> string(59) "/hsphere/local/home/polaris/polaris.nozonenet.com/index.php" ["line"]=> int(36) ["args"]=> array(1) { [0]=> string(67) "/hsphere/local/home/polaris/master/jojocms-1.0rc1/includes/jojo.php" } ["function"]=> string(12) "require_once" } }


how come first site table prefix gets appended there.
tnx for great free jojocms
dennyhalim

13 May 2009
Posts: 44

and when setup third and fourth site, the second site's tableprefix (but not the first site tableprefix) get appended there.
tnx for great free jojocms
mikec

Lead Developer

mikec

14 May 2009
Posts: 67

Ahh - I know the problem :-) I'll patch it and commit a fix shortly.
mikec

Lead Developer

mikec

14 May 2009
Posts: 67

Fixed in SVN. Give it a go and let me know if there's any more problems with it.
dennyhalim

14 May 2009
Posts: 44

pointed config.php to new svn folder.

now http://website/setup gives me error 404
?)
tnx for great free jojocms
mikec

Lead Developer

mikec

14 May 2009
Posts: 67

I think Harvey changed it so it needs the trailing / now.

So try http://website/setup/

- Mike
Harvey

Core Developer

Harvey

14 May 2009
Posts: 327

Yes, it does need the trailing slash. Michael Brandon found that any URI with the word 'setup' was matching against the setup script instead of the page.

eg www.domain.com/setup-instructions/

I'm sure a better fix is out there, but for now there is a good reason for that change.
dennyhalim

14 May 2009
Posts: 44

works! great!
everything ok. tnx a zillion.

now that it works, what should we consider with this setup?
i know the database will be much more busier.
that one thing for sure.

what else?
security issue? anything?

will this make it to rc2 anytime soon?

tnx again!
tnx for great free jojocms
Rick Rick

14 May 2009
Posts: 336

I wrote some elaborate code to play with then finally just thought why not use

if (strtolower(trim($_REQUEST['uri'], '/')) == 'setup') {
// Run setup stuff here
}


Wouldn't that work? that would stop 'instructions/setup/' etc from being caught up in the mix. But it relies on having the htaccess file there first.
tom

Developer

tom

14 May 2009
Posts: 379

problem i found was it needed to also catch ?resetlocation, i did try a bunch of options, but my regexing wasn't up to it, so i ended up going for the trailing slash as the most straightforward fix. Now that reset location is gone (?) it's probably not an issue to use that approach.
Harvey

Core Developer

Harvey

14 May 2009
Posts: 327

Reset location isn't needed in recent SVN copies. _SITEURL is now defined in the config file rather than in the database, which makes is a bundle easier for shifting a site around between dev, staging and live servers (because the config file is unique for different servers anyway).

I agree that setup should work regardless of whether there is a trailing slash or not.
dennyhalim

19 May 2009
Posts: 44

all setup successfully and no error.
all website running and admin look ok too.

but today, out of curiosity i run http://website/setup/ again
and it gives me:

Table fielddata column fd_flags exists but is different to expected - resolve this manually.
Found: `fd_flags` text collate latin1_general_ci NOT NULL
Expected: `fd_flags` text NOT NULL DEFAULT ''
SQL: ALTER TABLE fielddata CHANGE `fd_flags` `fd_flags` text NOT NULL DEFAULT '';


and a 'fix' button.
i click on the fix button and it gives:

Running SQL: ALTER TABLE fielddata CHANGE `fd_flags` `fd_flags` text NOT NULL DEFAULT '';
ALTER TABLE fielddata CHANGE `fd_flags` `fd_flags` text NOT NULL DEFAULT ''; Table 'polaris_jojosite.fielddata' doesn't exist


problem persist.

but all website and admin still function as if nothing happen.
tnx for great free jojocms
tom

Developer

tom

19 May 2009
Posts: 379

All is well. At some point we'll have a look at that and clean it up - it's a known issue - but apart from producing annoying messages at setup, it doesn't affect anything
dennyhalim

1 Jul 2009
Posts: 44

this setup is help a lot make setup new site takes only one single click.

but there's still one problem remains:
afaik, the only way to remove the test article is using phpmyadmin??

why is there a test article exist? why just give us empty article?
or a way to easily remove it from the admin?

tia
tnx for great free jojocms
Back to Forum Index : Back to Installation   RSS
You must be logged in to post a reply



You need to Register or Log In before posting on these forums.