Extension talk:Simple Farm
Contents
Thread title | Replies | Last modified |
---|---|---|
Combining Simple Farm with Short URL | 3 | 03:26, 7 October 2014 |
Is there a way to make this use the same database for the wikis? | 24 | 17:20, 9 November 2013 |
Developing a companion extension to allow wiki users to create new wikis | 0 | 17:03, 9 November 2013 |
Modifying .htaccess | 1 | 23:28, 8 September 2013 |
Great extension | 4 | 23:24, 8 September 2013 |
Images Not Displayed | 2 | 22:50, 20 July 2012 |
Shared Directories | 2 | 11:20, 14 July 2012 |
I'm wondering how to use short url with simple farm. I'm using scriptpath-based setup. I've added this rewrite rule and it worked fine, but with no short url.
RewriteRule ^(?!wiki(?:/|$))[^/]+(?:/(.*))?$ wiki/$1
I've tried to add rewrite rules for short url but with no success.
Some more information would be helpful for analyzing your problem. It works for me but I guess there are a few other factors such as global variables that could effect a positive outcome.
Here is my configuration: a folder named "fruits", and inside it another folder named "wiki" which contains the MediaWiki files.
I have the simple farm extension installed, with FarmMembers.php containing this code:
<?php $egSimpleFarmMembers = array( array( 'name' => 'Apple', 'db' => 'apple', 'addresses' => 'localhost', 'scriptpath' => '/fruits/apple', 'maintain' => false, ) ); ?>
apache2.conf file has the following configuration:
<Directory /var/www/html/fruits> Options +FollowSymlinks <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^(?!wiki(?:/|$))[^/]+(?:/(.*))?$ wiki/$1 </IfModule> </Directory>
This all works correctly but problems arise when I want to add short URL to it using the apache2.conf file. I tried to add short URL rewrite rules after the simple farm one, and tried to combine both, but with no success. Could you please tell me which rewrite rules did you write to get it to work successfully?
To make things clear, what I want to accomplish is a URL like this: localhost/fruits/apple/Main_Page and not localhost/fruits/apple/index.php/Main_Page .. i.e. removing the index.php part
Please read the comment provided together with the rewrite rule at Simple Farm - Setting-up Rewrite Rules for scriptpath based farm members.
It states No '/' allowed within the wiki path when using the rule
, referring to RewriteRule ^(?!wiki(?:/|$))[^/]+(?:/(.*))?$ wiki/$1
.
So if you are aiming for /fruits/apple
and /fruits/strawberry
instead of /apple
and /strawberry
you need to modify that rule accordingly, e.g. as in the example given in the very same code example from the section above: RewriteRule ^(?:fruits|fruits/apple|fruits/strawberry)(?:/(.*))?$ wiki/$1
Not sure you have anything else not configured accordingly, just try to change that first.
I'm wondering how I create new wikis, and I also want to use only one database.
Using only one DB is not supported currently (as described in the other topic already). When using multiple DBs, after you added your configuration for a new wiki, you have to run maintenance/update.php on that farm member.
Would it be simple to add the ability to use a single database?
I'm making a wiki hosting service and I'm working to make the wiki creation process as fast as possible. If each database on the farm used the same user, that would speed up the process, but it would still be an extra step.
I think the cost of implementation must be something around two to four working hours. I have not looked at the code for quite a while and I think there was some conceptual problem with why adding this right away was not possible, I think it was because currently the code is taking the data base name as ID for identifying the farm members. If multiple farm members should be allowed to share one database, we had to introduce some other field as the ID to identify farm members.
Around next month, I would have time implementing this if you are interested in hiring me. Of course you could also try implementing this on your own or creating a hack for this. If you submit a patch to gerrit, I would happy to review it.
I'm using multiple databases with a wildcard on the database user for the database prefix. That way the wiki creation process is simplified.
I can also add instructions to the page for how to do this and how it can be beneficial for services that need to be able to create wikis quickly.
I haven't been able to run the update script for a single wiki. What exactly is the command for it? I'm guessing from the instructions that it's
php www/extensions/SimpleFarm/maintenance/maintainFarm.php "php /home/path/to/www/maintenance/update.php" --farmonly=wikihost_mywikiBattlefield
Just navigate to your extensions/SimpleFarm/maintenance
directory and then execute php maintainFarm.php "php ../../../maintenance/update.php --farmonly=wikihost_mywikiBattlefield
.
Or even better, if only doing this for one wiki, you can simply run this from the root of your MW installation:
WIKI=wikihost_mywikiBattlefield php maintenance/update.php
When I run the command
php maintainFarm.php "/home/sasha/web_servers/mywiki.ssu.lt/www/maintenance/update.php" --farmonly=wikihost_mywikiBattlefield
I get this
~~ ~~ Simple Farm NOTE: No farm member selected in 'WIKI' environment var. ~~ Auto-selected main member 'wikihost_mywikiBattlefield'. ~~ ~~ The following 1 out of 2 farm members are selected: ~~ (1) Name: 'Battlefield_Wiki' DB: 'wikihost_mywikiBattlefield' ~~ Start maintaining selected 'Simple Farm' members: ~~ Command: '/home/sasha/web_servers/mywiki.ssu.lt/www/maintenance/update.php' ~~ (1/1) Running command for member 'Battlefield_Wiki' (WIKI=wikihost_mywikiBattlefield)... sh: 1: /home/sasha/web_servers/mywiki.ssu.lt/www/maintenance/update.php: Permission denied ~~ Finished! All 1 selected 'Simple Farm' members have been maintained ~~ WARNING: 1 of the command executions have returned a value implying an error. See output above!
There are no tables added to the database.
I'm working on an extension for WikiHub that will allow users to create new wikis from a special page for their convenience.
I'm working on a script here that can handle the new wiki creation.
I've also outlined the features of the extension on my development website and plan to include a method of tracking what wikis have been created and wiki creation by user. I don't think this will be implemented as a standard MediaWiki log, but as a database query from a special page that will gather all wikis created by a given user or by all users.
To simplify tracking of wiki creation, I will make the special page only accessible from a central wiki on the farm that will be designated as the main wiki where new wikis can be created from. For some farms this could be the community or meta wiki.
The extension page lists this as the content for .htaccess
# (c) 2011-2012 by Stephan Jauernick (http://stejau.org) # Distributed under ISC license RewriteEngine on # crazy magic: # this piece checks if we have mess with wiki stuff RewriteCond %{REQUEST_FILENAME} wiki$ # next rule sets a env var to a value which can be used to check if files are in shared code base RewriteRule ^/?wiki/(.*)$ - [E=REQUEST_FILENAME_W:%{DOCUMENT_ROOT}/w/$1] # check if file is existent in shared code base RewriteCond %{ENV:REQUEST_FILENAME_W} -d [OR] RewriteCond %{ENV:REQUEST_FILENAME_W} -f # if so: rewrite RewriteRule ^/?wiki/(.*)$ /w/$1 [PT,L,QSA] # standard rewrite magic: RewriteRule ^/?wiki/[Ii]ndex\.php/(.*)$ /w/index.php?title=$1 [PT,L,QSA,B] RewriteRule ^/?wiki/(.*)$ /w/index.php?title=$1 [PT,L,QSA,B] RewriteRule ^/?wiki$ /w/index.php [PT,L,QSA,B] RewriteRule ^/?images/(.*)$ /w/images/$1 [PT,L,QSA,B] RewriteRule ^wiki/images/(.*)$ /w/images/$1 [PT,L,QSA,B] RewriteCond %{REQUEST_URI} ^/$ RewriteRule ^/?$ /w/index.php
And I have the domain.tld/pagename setup. (yourwiki.mywiki.ssu.lt)
I changed it to this but it doesn't work.
# (c) 2011-2012 by Stephan Jauernick (http://stejau.org) # Distributed under ISC license RewriteEngine on # crazy magic: # this piece checks if we have mess with wiki stuff RewriteCond %{REQUEST_FILENAME} wiki$ # next rule sets a env var to a value which can be used to check if files are in shared code base RewriteRule ^/?(.*)$ - [E=REQUEST_FILENAME_W:%{DOCUMENT_ROOT}/$1] # check if file is existent in shared code base RewriteCond %{ENV:REQUEST_FILENAME_W} -d [OR] RewriteCond %{ENV:REQUEST_FILENAME_W} -f # if so: rewrite RewriteRule ^/?(.*)$ /$1 [PT,L,QSA] # standard rewrite magic: RewriteRule ^/?[Ii]ndex\.php/(.*)$ /index.php?title=$1 [PT,L,QSA,B] RewriteRule ^/?(.*)$ /index.php?title=$1 [PT,L,QSA,B] RewriteRule ^/?$ /index.php [PT,L,QSA,B] RewriteRule ^/?images/(.*)$ /images/$1 [PT,L,QSA,B] RewriteRule ^wiki/images/(.*)$ /images/$1 [PT,L,QSA,B] RewriteCond %{REQUEST_URI} ^/$ RewriteRule ^/?$ /index.php
Do you know what I should change it to?
This looks like you don't want the /wiki/
or /w/
part in your urls, is that right? I don't quite remember why it is or where I read it, but I remember that it is being discouraged from doing so in general, I tried it a few years ago and remember switching back to the old scheme because it wouldn't work well.
Hi, I think this is a great extension. Just to make sure that I understood correctly: This extension allows to install more than one wiki using different databases on a single server, using the same source code?! Cheers
That is right. It's not the only extension like that, there are at least two more, see Category:Wiki farm. Extension:WikiFarm though seems to have documentation in Russian only and Extension:Farmer requires changes on the MW code, also it has been reported broken quite often. Just read the documentation of Simple Farm and then you still need to use some rewrite rules on your web server, so all web-requests to the particular wikis are getting re-directed to the one MediaWiki installation with Simple Farm inside.
Cool. Heaps of cudos for you. For the very reasons you mentioned I refrained from using the two alternatives. Since I am not a coder I did not dare to try implementing the drupal-style approach on my own either. This is why I am happy to see this extension come to life. Cheers
What if you are using one database? I see the DB setting for the wiki configurations. Is it actually for a different database or is it just a table prefix?
Currently the extension does not support $wgDBprefix simply because I did not need it (I prefer one DB per wiki). Would not be too hard to implement this I guess.
Hi Danwe, I am pretty much done with my wiki farm. I had to alter your setup, since I use one shared database (per domain) for all wikis, and differentiate between them with prefixes. Since the prefix is not part of your extension, I use virtual database names instead. This works since you do not access the database within your extenson, so I can re-define the real database name after the farm is intialized.
The setup works fine but I have one issue left about not displaying any images or logos. I outlined a sample of my configuration on a separate page in oder to avoid messing up your talk page. I assume the issue is based on the rewrites in my .htaccess, but I can't figure it out. Do you mind looking at my my configuration and giving me a hint where I failed? Anybody else who is reading this, how can I modify my rewrites to access the images?
Hi Danwe, I found it eventually. The [B] opton in the rewrite rules escape the necessary colon between namespace and filename. I left it out, and voila: it works now :)
I'll look into this as well, perhaps I have to improve the rewrite rules. About DB prefixes: You could probably define a custom option in your $egSimpleFarmMembers entries, for example dbprefix, and then do Manual:$wgDBprefix = SimpleFarm::getActiveMember()->getCfgOption( 'dbprefix' );
I guess it would be problematic with all members having the same db option though, especially when it comes to maintenance. I will think about improving on this, hasn't been a priority though since I always use separate DBs for my wikis.
Hi, that is really great, and I appreciate not only the work you did but also you being just in time for me merging my separate wikis to a farm. I like especially that it does not force one to a special configuration; instead you can use wikis within the same or on different databases, and the same applies to the virtual addresses as you described.
Before I start using it, I have one question left though regarding the shared directory structure. I know how to set up separate /images directories per wiki if needed, and it is nice that I do not even have to think about symlinking /extensions, but the question is about directories like /cache. In former versions of wiki farms (e.g. with symlinks) it was documented that it shall not be shared between wikis. Did that change? I did not see any code related to that topic in your solution, but may have missed it. Do you have any (bad/good) experience with sharing the cache folder?
Hello Surak! I am not 100% sure about caching but there is this "cache" directory in the mw root but it is always empty and it seems to have no functionality. Also, the variable which refers to the cache ( $wgCacheDirectory is disabled by default, and if you want to enable it, just make sure that the path is different for all of your farm members, e.g. by using $wgCacheDirectory = "/cache/{$wgDBname}"
. About $wgFileCacheDirectory, this depends on $wgUploadDirectory anyhow (which is set by the extension to be {$IP}/images/images_{$wgDBname}
by default.