메뉴얼:위키 패밀리

From mediawiki.org
This page is a translated version of the page Manual:Wiki family and the translation is 28% complete.
Outdated translations are marked like this.

A wiki family is a collection of two or more wikis that run on the same server and share a common set of resources from the parent installation, while each wiki remains otherwise independent. This setup is an alternative to running fully separate installations of MediaWiki. It may be the preferred choice if the site admin wants to reduce the amount of work involved in managing multiple wikis, or cut down on inode usage. For this reason, some wiki hosting services opt for the wiki family model.

The best known implementation of a wiki family is the wiki farm, although other approaches are possible. A list of known wiki farms is available on WikiApiary .

다음은 하나 이상의 위키를 호스트하기 위한 미디어위키 설정 방법에 관한 지침입니다.

방법들

위키 팜

다음 단계는 동일한 버전의 미디어위키에서 여러 위키를 실행하기 위한 것입니다:

  1. 먼저 일반적으로 첫번째 위키를 설치하세요. 자세한 사항은, 매뉴얼:설치 가이드 를 참조합니다.
  2. Enable your web server to share your MediaWiki install with all wikis. For multiple (sub)domains, have your web server accept connections from all the relevant domains. For multiple subdirectories, you could use rewrite rules, aliases, or symlinks.
  3. 현재 위키를 감지하기 위해 LocalSettings.php의 상단에 코드를 추가하십시오. Note that if the argument to --wiki contains a hyphen, the argument will be split on the hyphen and the resulting two values assigned to MW_DB and MW_PREFIX, respectively. For wikis by domain name:
    $wikis = [
        'example.org' => 'examplewiki',
        'one.example.org' => 'onewiki',
    ];
    if ( defined( 'MW_DB' ) ) {
        // Automatically set from --wiki option to maintenance scripts
        $wikiID = MW_DB;
    } else {
        // Use MW_DB environment variable or map the domain name
        $wikiID = $_SERVER['MW_DB'] ?? $wikis[ $_SERVER['SERVER_NAME'] ?? '' ] ?? null;
        if ( !$wikiID ) {
            die( 'Unknown wiki.' );
        }
    }
    
    $wgLocalDatabases = $wgConf->wikis = array_values( $wikis );
    $wgDBname = $wikiID;
    $wgDBuser = 'mediawiki';
    
  4. 모든 위키에 대해 달라야 하는 설정을 구성합니다. 예를 들어:
    $wgCacheDirectory = "/tmp/mediawiki_cache/$wgDBname";
    $wgUploadDirectory = "$IP/images/$wgDBname";
    $wgUploadPath = "/w/images/$wgDBname";
    
  5. 위키별 재정의를 구성합니다. 여기에는 최소 $1 및 $2가 포함되어야 합니다. This should include at least $wgServer and $wgArticlePath.
    $wgConf->settings = [
        'wgServer' => [
            'examplewiki' => 'https://example.org',
            'onewiki' => 'https://one.example.org',
        ],
        'wgArticlePath' => [
            'default' => '/wiki',
        ],
        'wgSitename' => [
            'default' => 'Example',
            'onewiki' => 'One',
        ],
        'wgLogo' => [
            'default' => '/images/examplewiki/Example_logo.png',
        ],
        'wgLanguageCode' => [
            'default' => 'en',
            'onewiki' => 'pt',
        ],
    ];
    extract( $wgConf->getAll( $wgDBname  ) );
    
    This could be done from a separate file, e.g.:
    # LocalSettings.php
    $wgConf->settings = require __DIR__ . '/LocalSettings_overrides.php';
    
    # LocalSettings_overrides.php
    <?php
    return [
        'wgServer' => ..,
        ..,
    ];
    

새 위키를 만들려면 먼저 데이터베이스를 만들고 설정을 추가한 다음 php maintenance/update.php --wiki=mywiki을 실행합니다.

개별 설정 파일

이것은 동일 소스 코드 체크아웃을 이용하면서, 단일 서버에 하나 이상의 위키를 설치하도록 해줍니다.

  1. Install the first wiki as normal, via the web or CLI installer, which sets up your database and generates a LocalSettings.php file.
  1. After installation, rename the generated LocalSettings.php file to include the wiki ID (e.g. database name), like LocalSettings_mywiki.php.
  1. 만들고 싶은 각 위키만큼 1단계와 2단계를 반복합니다.
  1. Create a new LocalSettings.php file that will load the correct one.

As with the above wiki farm example, a --wiki argument containing a hyphen will be split on the hyphen into two values assigned to MW_DB and MW_PREFIX, respectively.

<?php
$wikis = [
    'example.org' => 'examplewiki',
    'one.example.org' => 'onewiki',
];
if ( defined( 'MW_DB' ) ) {
    // Automatically set from --wiki option to maintenance scripts
    $wikiID = MW_DB;
} else {
    // Use MW_DB environment variable or map the domain name
    $wikiID = $_SERVER['MW_DB'] ?? $wikis[ $_SERVER['SERVER_NAME'] ?? '' ] ?? null;
}

if ( $wikiID ) {
    require_once "LocalSettings_$wikiID.php";
} else {
    die( 'Unknown wiki.' );
}

// Add any settings that should apply to all wikis below this line
// -------

위키가 같은 도메인에 있지만 경로가 다른 경우 (예를 들면, example.org/wiki1, example.org/wiki2 등등) 다음과 같이 이용할 수 있습니다:

<?php
$wikis = [
    '/example' => 'examplewiki',
    '/w_example' => 'examplewiki',
    '/one' => 'onewiki',
    '/w_one' => 'onewiki',
];
if ( defined( 'MW_DB' ) ) {
    // Automatically set from --wiki option to maintenance scripts.
    $wikiID = MW_DB;
} else {
    $path = explode( '/', $_SERVER['REQUEST_URI'] ?? '', 3 )[1] ?? '';
    $wikiID = $_SERVER['MW_DB'] ?? $wikis[ $path ] ?? null;
}

if ( $wikiID ) {
    require_once "LocalSettings_$wikiID.php";
} else {
    die( 'Unknown wiki.' );
}
짧은 URL을 사용하는 경우 $wgArticlePath$wgScriptPath를 모두 추가해야 합니다.

드루팔 스타일의 사이트

This setup has the advantage of being completely transparent to users and reasonably secure in terms of the images directory.

  1. Create a base directory to contain all your MediaWiki files e.g. mkdir /home/web/mediawiki.
  2. Install MediaWiki and additional tools as usual to a version-declaring subdirectory (e.g., /home/web/mediawiki/mediawiki-1.10.0).
  3. Link the version-declaring directory to a code directory. e.g., ln -s /home/web/mediawiki/mediawiki-1.10.0 /home/web/mediawiki/code
  4. Create a sites directory to contain our images and settings: mkdir /home/web/mediawiki/sites
  5. Setup the wiki as normal from the /code directory.
  6. 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://example.com/mywiki, one would create the directory example.com.mywiki. e.g., mkdir /home/web/mediawiki/sites/example.com.mywiki. See the Drupal's settings.php file for more information on this.
  7. If you intend to use media files, create an images directory in your site directory. e.g., mkdir /home/web/mediawiki/sites/example.com.wiki/images. Make it writable as necessary.
  8. Place the Drupal-style LocalSettings.php file in your main directory: cp DrupalLocalSettings.php /home/web/mediawiki/code/LocalSettings.php
  9. Modify the LocalSettings.php of each subsite to point to the right places:
    1. First comment out the code relating to $IP, (lines 16-20 in 1.15.3) as this is set to the code directory by index.php.
    2. Next insert the following two lines to ensure that image files are accessible, e.g.: $wgUploadDirectory = "/home/web/mediawiki/sites/wiki.example.com/images"; and $wgUploadPath = "/images";. These need to be put somewhere after the call to DefaultSettings.php (line 25 in 1.15.3), as the variables will otherwise be reset.
    3. Make further modifications as required.
  10. Prepare your Apache 2 installation. Example site: wiki.example.com
    1. Create a link to the code directory, if required e.g. ln -s /home/web/mediawiki/code /home/web/wiki.example.com
    2. Create an appropriate virtual host configuration:
      <VirtualHost *:80>
          ServerAdmin me@example.com
          DocumentRoot /home/web/wiki.example.com
          ServerName wiki.example.com
          CustomLog /var/log/apache2/wiki.mysite.log common
          # Alias for the site to be accessible
            Alias /mediawiki/code /home/web/mediawiki/code
          # Alias for wiki so images work
            Alias /images /home/web/mediawiki/sites/wiki.example.com/images
          # If you want to password protect your site
          #  <Directory /home/web/wiki.example.com>
          #    AuthType Basic
          #    AuthName "My protected wiki"
          #    AuthUserFile /etc/apache2/htpasswd/users-mywiki
          #   require valid-user
          #  </Directory>
      </VirtualHost>
      
11. If you are setting the sites up locally, update your hosts file with the site names. 사이트가 이제 작동해야 합니다.

In my case, I made another copy of the code from which to install and update my LocalSettings.php and databases. Note that $_SERVER['HTTP_HOST'] in the companion Drupal code is undefined when running maintenance scripts from the command line, so this solution does not permit the use of maintenance scripts without some modification.

Ubuntu를 위한 수정된 드루팔 스타일의 메서드

A simplified method for multiple wikis and multiple (or nested) subwikis on Ubuntu/Kubuntu that is loosely based on the above method can be found at:

How wiki farms are handled in maintenance scripts

MediaWiki maintenance scripts (e.g. update.php) accept a --wiki argument that is passed to your LocalSettings.php file as the constants MW_DB, MW_PREFIX, and MW_WIKI_NAME. The entire value of the --wiki argument is the value of MW_WIKI_NAME.

If there is a dash in the --wiki argument, then the part before the dash is assigned to MW_DB and the part after the dash is assigned to MW_PREFIX.

This table demonstrates how this works:

How the --wiki argument is parsed.
--wiki MW_WIKI_NAME MW_DB MW_PREFIX
enwiki enwiki enwiki empty
enwiki-one enwiki-one enwiki one
enwiki-one-two enwiki-one-two enwiki one-two

Since there is no --wiki argument for web requests, they must be handled differently. Typically, the domain name and/or URL path is used to select a wiki.

위키 간 공유를 위한 팁

$wgForeignFileRepos 를 사용하여 위키에서 업로드된 미디어 파일을 공유할 수 있습니다. 이것은 위키백과에 대한 위키미디어 공용과 유사합니다.

예를 들어:

  • en.example.org - 영어
  • fr.example.org - 프랑스어
  • de.example.org - 독일어
  • pool.example.org - 모든 위키를 위한 공유 미디어 파일.
The above example uses the name "pool". Avoid using the name "commons" because this may conflict with the interwiki link also named commons for Wikimedia Commons.

Also avoid using the name "media" (e.g. media.example.org) as that may cause a conflict between your interwiki and the internal namespace Media: for accessing local media files, e.g. [[media:File.png]].

공유 데이터베이스 테이블

Consider using a shared database for user accounts. 사용자 계정에 공유 데이터베이스 사용을 고려하십시오. 공유 데이터베이스 테이블 설정에 대한 지침은 Manual:Shared database 를 참조하십시오.

인터위키

확장기능:인터위키 를 사용하여 모든 위키 간에 인터위키 링크를 만들 수 있습니다. If the wikis are language editions, it is recommended to name the interwiki prefix after the exact language code. For example, "de" for the German wiki in your family. This way, you can connect pages about the same subject using language links.

Adding [[de:Hauptseite]] on your English "Main Page" will create a link "Deutsch" in the languages sidebar. 자세한 내용은 Help:Interwiki linking 를 참조하세요.

If you have a central wiki for files, create a prefix for this as well. E.g. pool to https://pool.example.org/wiki/$1 and enable the "Forward" checkbox to recognise it as a local wiki in the same family.

올리기

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

It is useful 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 = "https://pool.example.org/index.php/Special:Upload";

In 1.17, you'll also have to set $wgUploadMissingFileUrl to be redirected to the pool-wiki on red links.

$wgUploadMissingFileUrl= "https://pool.example.org/index.php/Special:Upload";

If you want to allow uploads only for your pool wiki, you may use something like this:

if ( $wgDBname === 'pool' ) {
	$wgEnableUploads = true;
} else {
	$wgEnableUploads = false;
}

공유된 파일 사용

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

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

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

그림 설명

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

Change the text to something like:

This file is stored in our data-pool.
For information and description, please visit the [[:pool:File:{{PAGENAME}}|description there]].

(And note the ':' at the beginning of the line, which stops 'pool' from being included in the interwiki list at the left of the page.)

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 = "https://pool.example.org/index.php/Image:";

위키 팜 확장 기능

단일 코드 기반을 사용하여 여러 위키를 간단히 호스팅하기 위한 여러 미디어위키 확장 기능이 있지만, 현재 주목할만한 것은 단 하나뿐입니다:

같이 보기