维客网站群设置

来自Org
跳转至: 导航搜索

您当前所在的位置:首页 > 架设手册 > 维客网站群设置

维客网站群又称 Wiki Family 或者 Wiki Farm

设置起来有一些地方与单个或者多个独立的维客站点有一些不同,主要是希望能共享一些配置和数据库内容。


以下原文取自http://www.mediawiki.org/wiki/Manual:Wiki_family

This page should lead you through the installation and configuration of a small wiki-family.

Scenario 1: Unix-based operational system shared-hosting provider

You have a wiki installed in an Unix-based operational system shared-hosting provider. See the solution, including step-by-step detailed instructions: http://www.steverumberg.com/wiki/index.php/WikiHelp For a smaller guide and simpler solution, see Scenario 2, below.

Scenario 2: Quick set-up

You want to install more than one wiki on a single server, using the same source code, and using the same database?

  1. Install MediaWiki and additional tools as usual
  2. Set up your wiki (e.g., MyWiki)
  3. After successful installation, move LocalSettings.php into the root directory of your wiki and rename it in such a way to make it easy to track (e.g., myWikiLocalSettings.php)
  4. Repeat the steps above for each wiki you wish to create, with suitable local setting files (e.g., anotherWikiLocalSettings.php, etc.)
  5. Create a LocalSettings.php file for your global settings, then select one from the two possibilities below:
1. If your wikis are in different directories or subdomains linked to the same directory on your server, use this:
<?php

$callingurl = strtolower($_SERVER['REQUEST_URI']);        // identify the asking url
        
if ( strpos( $callingurl, 'wiki1') ) {
        require_once( 'wiki1LocalSettings.php' );    
}
else if ( strpos( $callingurl, 'wiki2') ) {
        require_once( 'wiki2LocalSettings.php' );    
}
.
.
.
else if ( strpos( $callingurl, 'wikiN') ) {
        require_once( 'wikiNLocalSettings.php' );
}
?>
OR 2: If you have different domains that link to one directory on your server, use this:
<?php
$callingurl = strtolower($_SERVER['SERVER_NAME']);

$pos = strpos( $callingurl, 'domain1'); //e.g. www.domain1.com
  
if ( $pos === false ) {
        require_once( 'LS1.php' );    
}
else
{
	require_once( 'LS2.php' );
}
?>

You can use a different unique MySQL database for each wiki (see $wgDBname) OR you can use a different table prefix for each wiki (for Postgres, you can achieve a similar effect by using different schemas) (see $wgDBprefix).

To link your subdomains to one directory on your server you may have to edit the configuration file for your server (can not be done with a .htaccess file) or modify the DNS configuration for your site (if your site has its own IP address).

Scenario 3: Drupal-style sites

As above, this setup allows you to install more than one wiki on a single server, using the same source code. This setup has the advantage of being completely transparent to users and reasonably secure in terms of the images directory.

  • Create a base directory to contain all your MediaWiki files e.g., mkdir /home/web/mediawiki.
  • Install MediaWiki and additional tools as usual to an version-declaring subdirectory(e.g., /home/web/mediawiki/mediawiki-1.10.0).
  • Link the version-declaring directory to a code directory. e.g., ln -s /home/web/mediawiki/mediawiki-1.10.0 /home/web/mediawiki/code
  • Create a sites directory to contain our images and settings: mkdir /home/web/mediawiki/sites
  • Setup the wiki as normal from the /code directory.
  • After successful installation, move LocalSettings.php into a sites directory that will be a match when the site is checked. For example, to capture http://mysite.com/mywiki, one would create the directory mysite.com.mywiki. e.g., mkdir /home/web/mediawiki/sites/mysite.com.mywiki. See the Drupal's settings.php file for more information on this.
  • If you intend to use media files, create an images directory in your site directory. e.g., mkdir /home/web/mediawiki/sites/mysite.com.wiki/images. Make it writable as necessary.
  • Place the Drupal-style LocalSettings.php file in your main directory: cp DrupalLocalSettings.php /home/web/mediawiki/code/LocalSettings.php
  • Modify your LocalSettings.php to point to the right places. The following modifications deserve special attention:
$IP = "/home/web/mediawiki/code";
$IPplus = "/home/web/mediawiki/sites/wiki.mysite.com";
$wgUploadDirectory  = "$IPplus/images";
  • Prepare your Apache 2 installation. Example site: wiki.mysite.com
    • ln -s /home/web/mediawiki/code /home/web/wiki.mysite.com
    • Create an appropriate VHost configuration:
<VirtualHost *:80>
    ServerAdmin me@myserver.com
    DocumentRoot /home/web/wiki.mysite.com
    ServerName wiki.mysite.com
    CustomLog /var/log/apache2/wiki.mysite.log common
    # Alias for Wiki so images work
      Alias /images /home/web/mediawiki/sites/wiki.mysite.com/images
    # If you want to password protect your site
    #  <Directory /home/web/wiki.mysite.com>
    #    AuthType Basic
    #    AuthName "My protected Wiki"
    #    AuthUserFile /etc/apache2/htpasswd/users-mywiki
    #   require valid-user
    #  </Directory>
</VirtualHost>


The site should now work. In my case, I made another copy of the code from which to install and update my LocalSettings.php and databases.


Scenario 4: Multiple wikis sharing common resources

You want to have some wikis in different languages, sharing the same media-files in another, single wiki.

For example:

  • en.yourwiki.org - english language
  • fr.yourwiki.org - french language
  • de.yourwiki.org - german language
  • pool.yourwiki.org - media-files for all of these wikis (like Commons).

Install

On your filesystem, create a folder for each wiki. Run the install script for each wiki. (This solution duplicates source code.)

Configure

Interwiki

Now you have to set Interwikilinks between all wikis, by editing their MySQL-Databases

  • Table Interwiki
    • iw_prefix - enter the language-code of the wikis, "de" for german, "en" for english, "fr" for france and "pool" for the mediapoolwiki
    • iw_url - this is the place for the complete URL to the wikis, e.g. "http://de.yourwiki.org/index.php/$1" for the german wiki (don't forget the "$1" !!!).

Now you can link an article to the same in another languages. Adding [[de:Hauptseite]] on your english Main_Page will create a link "Deutsch" (under the Navigation bar) which leads to the Main_Page of the german wiki (Hauptseite). For further information visit Help:Interwiki linking

Upload

Make sure that folder "images" of the pool-wiki is writable.

It is usefull to change the "Upload file"-Link of the language-wikis to point to poolwiki's upload-site. Open the "LocalSettings.php" of each language-wiki and add:

$wgUploadNavigationUrl = "http://pool.yourwiki.org/index.php/Special:Upload";

Use shared files

To use poolwiki's files in the languagewikis, open "LocalSettings.php" for each languagewiki and add:

$wgUseSharedUploads = true;
$wgSharedUploadPath = 'http://pool.yourwiki.org/images';
$wgSharedUploadDirectory = '/(LOCALPATH)/POOL-FOLDER/images/';
$wgHashedSharedUploadDirectory = true;

Now you can integrate pool's files with (e.g.) [[Image:MyLogo.png]] in the languagewikis.

Image description

In each languagewiki, open (as an admin) the message MediaWiki:Sharedupload.

Change the text to something like:

This file is stored in our data-pool. For information and description, please visit the  

[[:pool:Image:{{PAGENAME}}|description there]]. 
( And note the : at the beginning, if not, it would be parsed as another language (at least in 19alpha) )

If you want to output the media-description, stored in the PoolWiki, too, add to the "LocalSettings.php" of the languagewikis:

$wgFetchCommonsDescriptions = true;
$wgSharedUploadDBname = 'pool';  # DB-Name of PoolWiki
$wgSharedUploadDBprefix = 'wiki_'; # Table name prefix for PoolWiki
$wgRepositoryBaseUrl = "http://pool.yourwiki.org/index.php/Image:"; 

Shared ExtensionSettings.php file

If you have multiple wikis, you may be interested in sharing similar settings across them all. Here is how to do that.

  • Step 1
    Create a file called ExtensionSettings.php with the following contents, and place it anywhere outside of your wikis. (it can be anywhere you want, it's just easier to think of it as a global file if it's not in any single wiki directory.)
<?php
### Add globalized Extension settings below

?>
  • Step 2
    Edit the LocalSettings.php file of each wiki that you want to use the shared settings, and add the following.
require_once( "/absolute/path/to/ExtensionSettings.php" );
  • Step 3
    Now just add all the settings that you would like to be the same across all your wikis. Here are some examples of what to include.
    • References to your various extensions
    • Your database user name and password
    • Even your database table/prefix information can be included with a special technique
    • Really, almost everything that you currently customize in your LocalSettings.php file

模板:Languages

关于“维客网站群设置”的留言:

目前暂无留言

新增相关留言