|
Cookbook /
WikiFarmAlternativeSummary: An efficient way to manage a wiki farm or web server.
Version: 2.1
Maintainer: BenWilson
Discussion: WikiFarmAlternative-Talk
Categories: WikiFarms, CustomPageStore
Last Tested: This recipe was last tested on PmWiki version: pmwiki-2.2.0-beta68 Table of Contents QuestionI like the Wiki Farm Step By Step approach, but is there another way? AbstractPmWiki is a versatile tool for managing a web site. One under-recognized feature is Pmwiki's ability to manage several different web sites simultaneously from the same code base. This recipe demonstrates how a web administrator can configure PmWiki to service several sites while retaining the ability to smoothly handle upgrades. When implemented, this recipe provides centralized control of PmWiki administration. The final result is a web server that is easily maintained. This recipe can be applied in either a wiki farm or web site context. ImplementationThis recipe seeks to retain security while providing ease of administration and flexibility. For demonstration purposes, we will assume the administrator wants to manage three web sites: example.org, example.net, and example.com. The first step in this process is to build the framework in a non-web accessible directory. Using these sites as an example, the web directories would be: /var/httpd/hosts/example.org /var/httpd/hosts/example.net /var/httpd/hosts/example.com By way of background, I use the methods of this recipe to manage nearly a dozen wiki fields hosted on four co-located web sites. This recipe has allowed me to introduce seamless upgrades to all these sites while reducing the administrative overhead to running a simple shell script. Some of this recipe indicates my own personal ideocyncracies, such as explicitly setting configuration values rather than trust the PmWiki software to do it. This is because I've encountered some odd situations and this approach has worked in each, whereas I've had difficulties making it work following the PmWiki-way. Additionally, hard-coding these values reduces the unlikely possibility of PmWiki being subverted and those derived values being exploited. Some of the steps below set variables. As my approach is not entirely
consistent with PmWiki, I am trying to rein in this recipe. Therefore, I
will provide a sample Attach:WAF_example-farmconfig.php Δ with those
settings. (Pending release of Setting up the Centralized ConfigurationSo, let's use Core Directory Contents: /example.org /example.net /example.com
The The The I am going to designate a single file as the universal configuration
file. I typically call it As an alternative, Configuring the FieldsIn order to take advantage of this recipe, you will need to slightly amend the structure of the fields which use it. As of August 26, 2006, I am revising this recipe to break the steps into more discrete parts. So, where there is a section dedicated to a part you are interested in, please refer to that part. In each wiki field, you will want:
index.php
/pub -> {core_directory}/pmwiki-share/pub (if you can symlink, otherwise you'll have to copy)
/wiki.d (can be removed see below.)
/local
config.php
The structure above is the minimum of what you should have. The As suggested above, it is possible to move the wiki.d out of the web-accessible directory. As this directory has wide-open permissions, I believe it is inherently insecure to leave To further map the field to the central directory, you will want to create an index file. There is an example for both symlinkable and non-symlinkable configurations. in index.php (with symlinks): <?php Because we can use symlinks, the site administrator can have <?php
include_once('{core_directory}/pmwiki-share/version.php');
include_once("In this situation, the web administrator cannot use symlinks. To remedy
this, he creates a file that tracks the version
Contents of version.php <?php
$version = 'pmwiki-2.2.0-beta68'; # or $version = 'pmwiki_latest'; with symlinks.
$FarmS = '{core_directory}pmwiki-share';
$FarmC = '$FarmS/cookbook';
The actual version number would be whatever version you want to use. I move the variables into this common file so it is easy to change the values without having to hunt throughout a wiki plantation. Note: In both cases, the administrator forces the assignment of so there is no chance for PmWiki to get confused. This does not use the '../' approach as it is more secure to put in the full path. Also, this allows me to copy the index.php in sub-directories of a wiki farm and still find the correct version of pmwiki.php. My experience has been that an explicit definition of this variable remedies various problems I've encountered.
Pm suggests this is overkill. However, by explicitly defining a few critical directories here, I have experienced less headache. The only significant problem I've encountered using this approach is the occasional recipe that expects /cookbook to be in . In those situations, I usually fix that by substituting with $FarmC without much problem.
To access all recipes in the centralized include_once("$FarmC/{recipe.php}");
Note: you do not need to put the cookbook directory into each field! Just make sure the script knows where to look. I assign the location in index.php that works no matter where the field is. This leverages off of the centralization by allowing multiple fields to benefit from one recipe. To access commonly shared configurations: include_once("$FarmL/standard_configurations.php");
This is what is added to each wiki field's Local configurations You will create the "local/config.php" just like you would for a normal installation. Notice the commonly shared configurations can be site specific. So, if you have two sites, you may have /pmwiki-share
/local
common_config-example_org.php
common_config-example_com.php
Then, all fields of "example.org" can access the standard configuration thus: include_once("$FarmL/common_config-example_org.php");
If you want both example.com and example.org to share a common set of core configurations (e.g. common security recipes), put the configurations into a super-common configuration (e.g. "common_security.php") and have this included in the "common_config-{site_name}.php". Each field will include its own set of Cookbook recipes. I tend to run the same basic half dozen, so they are put into farmconfig.php, and each different recipe is then individually included via local.php. Moving Cookbook Out of the Web PathMoving the Move the Cookbook. The first step is simple: locate the
# Change from this:
include_once("cookbook/GreatRecipe.php");
# To this:
include_once("$FarmC/GreatRecipe.php"); # or
include_once("{core_directory}/pmwiki-share/cookbook/GreatRecipe.php");
Advantage of Moving /Cookbook Out of the Web Path. This solution offers certain benefits. The greatest benefit is the security improvement. Pm is aggressive about resolving potential security holes in the PmWiki core. However, not all recipe authors can be. Thus, by moving the recipe out of harm's way, the likelihood of a recipe being exploited is greatly reduced. The second advantage is the availability of the recipes to all fields. Disadvantage of Moving /Cookbook Out of the Web Path. This solution
offers certain tradeoffs. Recipes are authored by different developers.
As a consequence, each developer has a different approach to how he
refers to files outside of his recipe. Sometimes, he assumes that the
recipe is in the same directory as his is. Othertimes, he tries to
recruit
define('GREATRECIPEPATH', dirname(__File__) . '/'); # or
define('COOKBOOKPATH', dirname(__File__) . '/');
Moving wiki.d Out of the Web PathIf you also want to move the wiki.d outside the web area, just remember
to set {core_directory}
/pmwiki-share
/work
/example_org-wiki.d
/example_com-wiki.d
/example_net-wiki.d
Linking to Non-Web Path Wiki.D Before we change PmWiki's behavior,
I'd like to briefly mention some relevant variables. There are three
variables that are affected: In the shared configuration, we are going to rebuild the
$WorkDir = "$FarmS/work/$WikiD/";
$LastModFile = "$WorkDir.lastmod";
$WikiDir = new PageStore("$WorkDir\$FullName", 1);
$WikiLibDirs = array(
&$WikiDir,
new PageStore("$FarmM/work/share.d/\$FullName"),
new PageStore("$FarmD/wikilib.d/\$FullName")
);
Advantage of Moving Wiki.d Out of the Web Path. This solution
offers certain benefits. The chief advantage of moving Disadvantage of Moving Wiki.d Out of the Web Path. This solution
offers certain tradeoffs. The chief disadvantage results from having to
configure PmWiki to behave outside its default behavior. Also, by
grouping all Moving /pub Out of the Web PathThis solution presumes Pm will be implementing Relocating /pub directory. The first step is to relocate the Configure Skin Location. Not implemented
$SkinLibDirs = array('{core_directory}/pmwiki-share/pub');
Configure /pub Location for Web Server. Not implemented
Once
RewriteRule ^/pub/?(.*) {core_directory}/pmwiki-share/pub/$1 [L,qsa]
Alternate: Symlink to /pub. If you are unable to implement the Advantage of Moving /pub Out of the Web Path. Of course, with
every solution there needs to be a reason. The advantage to moving this directory out of the web path is largely administrative. When you manage several wiki fields that share the same skins, javascripts or CSS files, then you may prefer to update that file one time and have that update effective on all fields simultaneously. This solution provides that advantage. Additionally, not having multiple copies of the Disadvantage of Moving /pub Out of the Web Path. All solutions offer some trade off. The disadvantage to this solution is that there is some overhead involved by editing files and some potential debuggery of the Advantage: UpgradesThe real advantage with this recipe lies in the ability to upgrade. When you are in a symlink situation, here is what you need to do:
Code:
wget -c http://www.pmwiki.org/pub/pmwiki/pmwiki-latest.tgz
tar xvfz pmwiki-latest.tgz
rm pmwiki-latest
ln -sf pmwiki-2.2.0-beta68 pmwiki-latest
Without symlinking, you still follow the first two steps. Instead of
steps three and four, you would instead edit
In both cases, if the new installation does not work, just reverse the version assignment (i.e, revert the symlink change, or edit back the older, stable version number). ReleasesAugust 26, 2006. BenWilson August 26, 2006, at 03:33 PM August 13, 2006. Added solution for moving wiki.d directories out of the web-accessible directory. BenWilson August 13, 2006, at 03:33 PM July 2, 2006. I am trying a new rewrite to help clarify some confusion raised. BenWilson July 02, 2006, at 03:33 PM February 10, 2006. I have used this to host multiple sites on the same server-where each site has its own Farm. I am making this available to other administrators. BenWilson February 10, 2006, at 03:33 PM CommentsComments to this recipe are available on its discussion page. Past discussions are also archived there. See AlsoContributorsCategories: WikiFarms Ben Wilson Maintained
|