User:Buehl106/sandbox

I've been translating.Don't edit.
この文章はバージョン1.37.1を元に翻訳中ですが正確性は一切保証されません。
Relinquish copyright.Contents of this page is public domain.

これはCentralAuth のチュートリアルで、できるだけシンプルにすることを目的としています。 もしこのガイドを編集する場合、シンプルになるようにしておきましょう。

ステップ 1, ウェブにダウンロード&インストール edit

初めに, いくつのウィキが必要ですか? "metawiki", "testwiki", "codwiki" という3つのウィキを使って説明します。

MediaWikiをダウンロードしましょう。このガイドは、あなたがLinuxシステム上で動作させていることを前提にしています。 CentralAuthはWindowsサーバー上でも実行可能ですがこのガイドではそのやり方を説明しません.

sudo -s && cd /

その時に

git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/CentralAuth.git

That will download the latest development centralauth to a folder called CentralAuth into the root (top) directory of your system.. While snapshots can be used, subversion is preferred.

次に, we will install MediaWiki as usual, with some considerations taken into account. Create your directories. In my case, i'm calling them metawiki, codwiki and testwiki. I'm using databases named named cod_wiki, test_wiki and meta_wiki. Note how the databases have a similar suffix. Make the account details the same across all installs, as they will be merged together later.

これでインストールが終了しました。 (using the exact same database username and password for each wiki). LocalSettings.php, 等のダウンロードも完了です。 Repeat for each wiki.

if you don't use the same un/pw for each wiki, you must grant all privileges on each wiki's database and the centralauth database, to each of the wiki's dbUser identified by each dbPass. (noted in each LocalSettings.php). Tl;dr use the same username and password.

全てのウィキの'extensions'フォルダーに(ダウンロードした)CentralAuthをアップロードします.

ステップ 2. Configure CentralAuth Settings edit

拡張機能をインストールしてセットアップしましょう。. セットアップスクリプトは全てのウィキで同じにしなければなりません。または conflicts will ensue. I'm keeping this simple - so here the example code. Copy and paste this code into your LocalSettings.php, and modify to your needs. I've commented to the side. The important things are to replace the database names with the databases you created, and to change sitename and directory locations. Remember, copy this script to the bottom of 全ての ウィキの LocalSettings.php.

Notice that your $wgConf configuration is included in this.

コード edit

wfLoadExtension( 'CentralAuth' );
 //拡張機能を読み込みます。 pretty self-explanatory

# General CentralAuth configuration
$wgCentralAuthAutoNew = true;
$wgCentralAuthDatabase = 'database name'; // デフォルトでは'centralauth'と設定
$wgCentralAuthAutoMigrate = true;
#$wgCentralAuthCookieDomain = '';
 
# Create the local account on pageview, set false to require a local login to create it.
$wgCentralAuthCreateOnView = true;
 
# Skips the "login success" page
$wgCentralAuthSilentLogin = true;
 
# Deprecated, will be removed soon.
$wgCentralAuthUseOldAutoLogin = false;

$wgCentralAuthDryRun = false;
    # unset( $wgGroupPermissions['*']['centralauth-merge'] );
    # $wgGroupPermissions['sysop']['centralauth-merge'] = true;
 
// You can't just set wgConf values to the globals defined in Setup.php for your
// ローカルなウィキでは, それはまだ実行していないからです.  You could hard-code $wgConf settings
// here, but instead we set the wgConf values in a hook that runs later.

$wgConf = new SiteConfiguration;
 
# Read wiki lists
 
$wgLocalDatabases = array( 'meta_wiki', 'test_wiki', 'cod_wiki' ); //all wiki databases, as an array. 重要な変更です.

$wgConf->wikis = $wgLocalDatabases;
$wgConf->suffixes = array(
        'wiki'
); //We have the same suffix of wiki
//all databases have suffix wiki
$wgConf->suffixes = $wgLocalDatabases;
 
$wgConf->localVHosts = array( 'localhost' ); //your database server. could be example.com or IP address. no http://
 
$wgConf->siteParamsCallback = 'efGetSiteParams';
$wgConf->extractAllGlobals( $wgDBname );

 
$wgConf->settings = array(
 
'wgServer' => array(
    'default' => 'http://localhost', //default means applied to all wikis. We want our location to be http://localhost/(wiki). If your wikis are hosted on different domains, then you would override this, but let's keep it simple
),
 
'wgCanonicalServer' => array(
    'default' => 'http://localhost',
),

'wgScriptPath' => array(
    'meta_wiki' => '/metawiki', //script path, where index.php is located for meta
'test_wiki' => '/testwiki', //test
'cod_wiki' => '/codwiki', //cod
),
 
'wgArticlePath' => array(
    'meta_wiki' => '/meta/$1', //for short urls
'test_wiki' => '/test/$1',
'cod_wiki' => '/cod/$1',
),

//IF IT'S NOT WORKING
//keep articlepath the same as scriptpath, with /$1 at the end. So for test_wiki it would be /testwiki and /testwiki/$1
 
'wgLanguageCode' => array( //dont change, if all wikis are english *BE careful not to alter this line if you use RegEx to replace COD with your wiki name!
    'default' => '$lang',
),
 
'wgLocalInterwiki' => array(
    'default' => '$lang',
),
);
 
function efGetSiteParams( $conf, $wiki ) {
    $site = null;
    $lang = null;
    foreach( $conf->suffixes as $suffix ) {
        if ( substr( $wiki, -strlen( $suffix ) ) == $suffix ) {
            $site = $suffix;
            $lang = substr( $wiki, 0, -strlen( $suffix ) );
            break;
        }
    }
    return array(
        'suffix' => $site,
        'lang' => $lang,
        'params' => array(
            'lang' => $lang,
            'site' => $site,
            'wiki' => $wiki,
        ),
        'tags' => array(),
    );
}


Begin by copying into one localsettings, modify, save and copy to the rest.

ステップ 3. centralauthのデータベースの作成 (and configure) edit

まだウィキは動きません. 他のことをする必要があります. Create a new sql database and call it 'CentralAuth'. Run centralauth.sql -- if you don't know how to do this the easiest way is to use a tool called phpMyAdmin. centralauth.sql is located in the CA folder in your root directory if you used the svn command line above. This writes tables, and sets up the database

Now we have centralauth set up, but nobody is configured to manage it. We need to create our global account, by migrating everyone. ウィキを選んで下さい。 I shall choose meta, and use terminal to chdir into it.

cd /path/to/mediawiki/extensions/CentralAuth/maintenance

Now type

php migratePass0.php

then

php migratePass1.php

You can run this process from each of your wiki's CentralAuth/Migration directories, but it may be easier to use Special:MergeAccount. So go to your other wikis (COD and TEST in my case) and go to Special:MergeAccount

Now, back to meta. go to Special:UserRights, and make yourself a 'steward'. The problem now is: steward is a local group, we need to migrate it to global. Back to terminal, hopefully you're still where we were before

php migrateStewards.php

You're now a global steward, good for you! What can you do - nothing, yet. You may want to remove your local steward group via Special:UserRights, it's no longer needed.

Since Special:GlobalGroupPermissions is only usable by users with the globalgrouppermissions user right from a global group, we have to insert the first user right manually via SQL management (e.g. phpMyAdmin or via shell). Using the centralauth database, run:

INSERT INTO global_group_permissions (ggp_group,ggp_permission) VALUES ('steward','globalgrouppermissions'),('steward','globalgroupmembership');

Now you have the authority to manage global groups through Special:GlobalGroupPermissions. Edit steward, which you are conveniently already member of, and tick everything you want (for me, everything except "bot" and "mark rollback as bot".) You can create new global groups through Special:GlobalGroupPermissions, and add people to it at Special:GlobalUserRights.

Special:CentralAuth lets you lock accounts globally, hide them, and unmerge them. I suggest installing global IP blocking, which is self explanatory.

ステップ 4, Configure global login settings edit

最後に, もう一つの事をしなければなりません。 You're obviously going to want accounts to be merged at creation. 以下をLocalSettings.phpに追加する必要があります:

$wgCentralAuthAutoNew = true;

There are a few other wgSettings there you may want to configure, such as auto-login for all wikis. These are explained in the comments in extensions/CentralAuth/CentralAuth.php and elsewhere on the net.

CentralAuth.phpは絶対に編集しないで下さい。 itself or your changes may be lost if you upgrade the extension.

Extra Credit edit

Also, if you want, you can get rid of the now useless local stewards group, by deleting the following. Wikipedia doesn't - but there is no real reason to keep it.

$wgGroupPermissions['steward']['centralauth-unmerge'] = true;
$wgGroupPermissions['steward']['centralauth-lock'] = true;
$wgGroupPermissions['steward']['centralauth-suppress'] = true;

If you keep them, its recommended you don't allow 'crats to add people to local steward, refer Manual:$wgAddGroups.

But individual configuration takes so long, how did the WMF do this for each of their wikis? edit

The WMF didn't take this approach. They use a commonsettings.php file that sets up all the wikis, but that's complicated to explain. For 3 wikis, copy and paste is the easier approach. In fact if you were thinking of taking the commonsettings approach, you probably wouldn't have come here.

できない! edit

CentralAuthについて試したり、拡張機能のトークページやこのガイドページのトークで質問したりしてみましょう。落ち込まないで, this along with Farmer is one of the hardest extensions to get running. Have you considered $wgSharedDB ?