User:Zhangjintao/zh

-{zh-hans:快捷方式;zh-hant:捷徑}-: FAQ
From mediawiki.org
Immediate help
  • mediawiki-l, the MediaWiki mailing list.
  • #mediawiki connect - the IRC channel.
  • Support desk
For a complete list of support venues, see -{zh-hans:联系交流;zh-hant:聯繫交流;}- .
关于MediaWiki使用的常见问题解答(FAQ)。 如果您的问题既没有在此处也没有在MediaWiki技术文档MediaWiki用户文档中得到回答,请在支持场所询问。


本FAQ是英文版的译本,可能不是最新的.

一言以蔽之[edit]

MediaWiki, Wikimedia(维基媒体基金会), Wikipedia(维基百科)和wiki间的区别是什么?[edit]

这个问题经常被问到,请参阅Wikipedia、Wikimedia、MediaWiki 和 wiki 的区别页面获得更详细的答案.

我能将MediaWiki用于某个用途么?[edit]

MediaWiki是自由软件,这意味着你可以以任意方式使用它而不需要法律上的许可.你的wiki上的内容可以采用不同的协议.当然,作为支持维基百科运行的软件而发展起来的项目,我们鼓励你使用一个自由许可证授权你的wiki上的内容,但是这不是必须的.

如果你希望修改MediaWiki软件,没有问题!但是这里有一些限制,查看GNU 通用公共许可证第二版的全文了解详细信息.因为MediaWiki是免费使用的,在适用的法律允许的范围内没有担保责任。

安装和设置[edit]

到哪里里下载MediaWiki?[edit]

点击这里前往下载页.你会下载到一个.tar.gz归档文件. 你也可以 通过Git从我们的版本库中下载 .

如何安装MediaWiki?[edit]

安装MediaWiki的预计时间为10到30分钟,包括上传与复制文件,和运行设置脚本.请参阅[Manual:Installation guide|安装指南]],你也可以在那里找到系统需求.

能通过软件包管理器安装MediaWiki吗?[edit]

大部分Linux发行版都会以分发包的格式提供MediaWiki软件。MediaWiki开发团队认为您应该向您的Linux发行版提供者咨询安装与配置的事宜。负责维护这些分发包的独立社群和公司应该向您提供安装指南。

但是请注意因为软件源中的MediaWiki可能不是最新的,所以请密切关注你所使用的扩展的兼容性。

另请参阅: MediaWiki软件套装(英文)

我能在一个服务器上运行多个MediaWiki网站吗?[edit]

只要满足下列条件,您就可以在一台服务器上安装多个wiki:

  • 您的每一个wiki使用各自不同的数据库

或者

  • 您的每一个wiki的数据库前缀不相同(如果您用的是PostgreSQL,在不同的模式或用户下,也能达到这一效果)

要了解这些选项的相关信息,可分别参见$wgDBname$wgDBprefix

要了解设置wiki家族的相关信息,可参见Manual:Wiki家族

要了解将多个wiki设置为使用相同服务器、数据库与资源的其他方法,参见来自Steve Rumberg存档)用户的更深层的解释与进一步的意见。

MediaWiki能在安全模式下工作吗?[edit]

可以,但其功能会受到一定限制。参见安全模式

MediaWiki需要Shell访问吗?[edit]

终端访问(SSH访问)在安装MediaWiki的过程中并不是必须的,但我们强烈推荐你这么做。如果不能进行终端访问,您可能难以对您的wiki进行备份,或难以将它升级到更新的版本。如果完全脱离终端访问,您将不能完成一些维护任务。

如何安装扩展?[edit]

参见Manual:Extensions获取安装插件与编写插件的相关信息。参见Category:插件以寻找已有的插件。

如何添加额外的名字空间?[edit]

参阅Creating a custom namespace.

如何启用文件上传?[edit]

文件上传是MediaWiki常用的功能之一,但在目前所有的发行版中都被默认关闭了。要启用它们,首先要让网站服务器上的上传文件夹(默认为images)可被写入(chmod 777或允许Apache用户写入内容,等等),然后在LocalSettings.php中将$wgEnableUploads设为true值(例如“$wgEnableUploads = true;”)。如果你在上传时遇到了一个"failed to mkdir" (无法创建文件夹)错误,你可能需要调整你的服务器上的文件权限。

也请参阅:Manual:Configuring file uploads

如何在MediaWiki中显示数学公式?[edit]

MediaWiki允许用户插入数学公式。参见Manual:Math获取安装指南。

如何设置我的Wiki的时区?[edit]

请参阅: Manual:Timezone

如何强制刷新一个缓存页面?[edit]

有时您需要刷新被缓存的页面,比如当页面的导航栏发生了变化后。在页面的动态URL后加上&action=purge即可。

例如:http://www.mediawiki.org/w/index.php?title=Main_Page&action=purge

或在页面的短型URL后加上?action=purge

例如:http://www.mediawiki.org/wiki/Main_Page?action=purge

也请参阅:Manual:Purge, Manual:Parameters to index.php.

如何完全停用缓存?[edit]

将下列语句加入LocalSettings.php即可:

$wgEnableParserCache = false;
$wgCachePages = false;

如何允许上传其他格式的文件?[edit]

MediaWiki 使用$wgFileExtensions来限定允许上传的文件格式.

例如,要允许用户上传PDF格式文件,请将下面一行增加到你的LocalSettings.php中:

$wgFileExtensions[] = 'pdf';

可以像下面这样一次添加多个文件类型:

$wgFileExtensions = array_merge($wgFileExtensions, array( 'pdf', 'txt', 'mp3' ));
也请参阅:Special:MyLanguage/Manual:Configuring file uploads

"文件已损坏或者扩展名不正确"[edit]

有些用户报告说,在向已允许扩展名列表中增加文件格式后,软件会发生错误。出错后的文字类似于下方:

文件已损坏或存在无效扩展名。请重新检查并上传文件。

可能的解决方案:

    *设定$wgMimeDetectorCommand的值,例如:在Unix或Linux,您可以将它设为
     :$wgMimeDetectorCommand = "file --brief --mime";
    • 编译/安装PHP插件fileinfo
      • Fedora - yum install php-pecl-Fileinfo
也请参阅:Manual:Mime type detection.code>

安装程序没创建一个管理员用户?[edit]

有时可能因为安装程序没有成功运行或是用户表丢失的缘故导致没有管理员账户,这里有几个修复的方法:

maintenance/createAndPromote.php[edit]

  • 对于1.16以前版本的MediaWiki,确保AdminSettings.php 配置正确(参阅AdminSettings.sample)
  • 在shell中运行 maintenance/createAndPromote.php --username <新用户名> --password <密码> . 要让新创建的用户既成为管理员又成为行政员,加入--bureaucrat 参数.

这会创建一个新用户并授予管理员权限,运行 createAndPromote.php--help获得帮助.

在数据库中修改[edit]

  • 用一般方法注册一个账户 (Special:UserLogin).
  • Special:Preferences 中查看用户ID.
  • 在数据库中执行下列SQL语句:
    • INSERT INTO user_groups ( ug_user, ug_group ) VALUES ( <id>, 'bureaucrat' ), ( <id>, 'sysop' );
<id>.用你刚刚查阅的用户ID替换.
注意: 如果LocalSettings.php中定义了 $wgDBprefix ,记得加在表名前.例如 $wgDBprefix = "XYZ"时的表名是 XYZuser_groups.

临时允许任何人修改用户权限,然后给初始化时创建的用户分配权限[edit]

警告 警告: 最好在进行这项操作时关闭你的wiki的外部访问,因为此时你的wiki更容易受到破坏.

为了能修改用户权限,这个操作的关键是允许所有用户修改权限.

  • 用一般方法注册一个账户 (Special:UserLogin),然后登录.
  • 在LocalSettings.php中加入下面一行

$wgAddGroups['user'] = true;

  • special:userrights中将新创建的用户添加到管理员与行政员组.
  • .将刚刚添加的$wgAddGroups['user'] = true; 删除
  • Remove the $wgAddGroups['user'] = true; line from your LocalSettings.php . This step is very important, as until you remove it anyone can alter permissions, which is bad.

如何重置密码?[edit]

参阅 Manual:Resetting passwords

如何创建或修改跨wiki链接?[edit]

参阅 Manual:Interwiki

如何让显示的URL更短?[edit]

(例如用 /wiki/Article_Name as opposed 取代 /w/index.php?title=Article_Name)

参阅 Manual:Short URL

我能像目录一样组织页面吗,像/wiki/subdir/PageName这样?[edit]

参阅 Manual:$wgNamespacesWithSubpages, Help:Subpages

下载和使用MediaWiki是免费的吗?[edit]

是的,在自由软件意义下的自由。参见Project:Copyrights了解本站已有内容在许可协议方面的问题。

如何管理用户权限?[edit]

参见Manual:用户权限Manual:用户权限管理获取常见的信息。参见Manual:访问控制获取限制访问的方法与措施。

如何阻止匿名用户编辑页面?[edit]

建议修改$wgGroupPermissions. 添加下面一行到LocalSettings.php:

$wgGroupPermissions['*']['edit'] = false;

通过Extension:AbuseFilter,管理员可以临时阻止匿名编辑.

也请参阅:阻止访问, Manual:User rights.

如何阻止匿名用户创建页面?[edit]

$wgGroupPermissions['*']['read'] = false;

也请参阅 Manual:$wgWhitelistRead. 参阅Manual:Preventing access#Restrict viewing of all pages for more information.

如何阻止创建账户?[edit]

$wgGroupPermissions['*']['createaccount'] = false;

参阅Manual:Preventing access#Restrict account creation for more information.

如何在注册时要求提供电子邮件地址?[edit]

参阅Manual:$wgEmailConfirmToEdit

如何让MediaWiki只读?[edit]

MediaWiki版本:
1.5
参阅Manual:$wgReadOnly

如何修改默认的用户设置?[edit]

MediaWiki版本:
1.4

MediaWiki 将默认的用户选项保存在语言文件中,例如languages/Language.php.但是和DefaultSettings.php一样,别修改它,做参考就好.

在Language.php查找你要修改的选项,例如:

 /* private */ $wgDefaultUserOptionsEn = array(
        ...
        'searchlimit'  => 20,
        ...
 )

要改成50的话,在LocalSettings.php里添加:

 $wgDefaultUserOptions = array( 'searchlimit' => 50 );

注意是设置$wgDefaultUserOptions,而不是$wgDefaultUserOptionsEn.

要改变默认搜索的名字空间,在LocalSettings.php里设置$wgNamespacesToBeSearchedDefault.例如要默认搜索主名字空间和分类名字空间:

 $wgNamespacesToBeSearchedDefault = array(
     NS_MAIN => true,
     NS_CATEGORY => true,
 );

某些情况下,你在改变默认设置后希望改变现有用户的设置.

要这样做的话,在maintaince目录运行userOptions.php. 第一次运行建议加入 "--dry" 参数(这个参数用来模拟运行,不会修改数据库。)。

php userOptions.php --dry --nowarn searchlimit --old 20 --new 50

另外,在进行实际操作前建议备份数据库。

也请参阅:Manual:$wgDefaultUserOptions

如何优化MediaWiki的运行速度?[edit]

请参阅: Manual:Performance tuning

如何启用搜索建议?[edit]

请参阅: Manual:Enabling autocomplete in search box

升级[edit]

请参阅: Manual:Upgrading

移动[edit]

能把我的wiki移动到另一台电脑上吗?[edit]

应该可以,实质上就是备份你的安装然后"还原"到一台新电脑上.然后对配置进行一些适当的调整以适合新服务器的需要.

那么,如何做?[edit]

参阅 Manual:Moving a wiki.

定制界面[edit]

如何修改左上角的标志?[edit]

左上角的标志是由LocalSettings.php中的$wgLogo选项决定.

有两个方法可以修改:

  1. 通过标准上传界面向你的wiki上传一张图片,这样以后修改起来也容易,所以你可能希望保护它防止被篡改.
    LocalSettings.php添加$wgLogo参数, 例如:
    $wgLogo = "{$wgUploadPath}/6/62/mylogo.png";
    
  2. 或者向服务器直接上传一张图片.
    LocalSettings.php添加$wgLogo参数, 例如:
    $wgLogo = "{$wgScriptPath}/mylogo.jpg";
    
    (这个例子中图片和LocalSettings.php在一个文件夹中.)

要改变某些页面的标志,覆盖#p-logo的background-image属性,或者使用像Extension:LogoFunctions这样的扩展.

小心! 小心: 别覆盖默认的logo (/skins/common/images/wiki.png); 因为升级时会被覆盖.
135x135px 或 150x150px是合适的logo大小. 最大的logo大小是 ~160x160px(Vector), ~155x155px(Monobook). 过大的部分会被裁剪.

如何编辑wiki的CSS?[edit]

别直接编辑像main.css一类的CSS文件,因为这样会使你日后的升级变得困难.要改变全站的样式,编辑MediaWiki:Common.css,要改变特定皮肤的样式(例如Monobook),编辑MediaWiki:Monobook.css.这些页面的内容会覆盖main.css中的值.


如何隐藏左侧的导航栏[edit]

换句话说,你希望内容占据全部的宽度来隐藏logo和左侧导航? 要隐藏它们,将下面的代码添加到MediaWiki:Common.css中.

#column-content { margin: 0 0 .6em 0; }
#content { margin: 2.8em 0 0 0; }
#p-logo, .generated-sidebar, #p-lang, #p-tb, #p-search { display:none; }
#p-cactions { left: .1em; }

要只在用户按下F11时隐藏,将下面的代码添加到 MediaWiki:Common.js:

document.onkeydown = function( e ) { if( e == null ) e = event if( testKey( e, 122 ) ) { //F11 appendCSS('#column-content {margin: 0 0 .6em 0;} #content {margin: 2.8em 0 0 0;} #p-logo, .generated-sidebar, #p-lang, #p-tb, #p-search {display:none;} #p-cactions {left: .1em;} #footer {display:none;}'); return false; } } function testKey( e, intKeyCode ) { if( window.createPopup ) return e.keyCode == intKeyCode else return e.which == intKeyCode }

如何隐藏页面底部的分类列表?[edit]

添加这一行到你wiki的MediaWiki:Common.css

.catlinks { display: none; }

我能自定义左侧顶部的标志吗,如果可以的话,怎样做?[edit]

  • 要修改标志的图片,参阅上节.
  • 要修改样式,在样式表中为#p-logo选择器定义样式即可,默认的样式像这样:
#p-logo {
	z-index: 3;
	position: absolute; /*needed to use z-index */
	top: 0;
	left: 0;
	height: 155px;
	width: 12em;
	overflow: visible;
}

记住,要编辑你wiki上的MediaWiki:Common.css一类的页面而不是直接修改核心css文件.


如何改变点击左上角的标志后跳转到的页面?[edit]

默认情况下点击logo会返回到首页,要指定哪一个页面是首页,编辑MediaWiki:Mainpage.

要在点击logo时前往任意的其他页面(不一定是你的wiki),你可以向LocalSettings.php中增加一个hook来覆盖默认设置.

/* 改变首页的URL为绝对路径 */
$wgHooks['SkinTemplateOutputPageBeforeExec'][] = 'lfChangeMainPageURL';
function lfChangeMainPageURL( $sk, &$tpl ) {
	$tpl->data['nav_urls']['mainpage']['href'] = "http://www.your-desired-url.com/"; // Point the main page url to an absolute url
	return true;
}

/* Change the main page url used in things like the logo to a url of another page on the wiki */
$wgHooks['SkinTemplateOutputPageBeforeExec'][] = 'lfChangeMainPageURL';
function lfChangeMainPageURL( $sk, &$tpl ) {
	$tpl->data['nav_urls']['mainpage']['href'] = Title::newFromText('ThePage')->getLocalURL(); // Point the main page url to a wiki page's url
	return true;
}

改变标志的大小[edit]

Note that a tag is on top of the logo so if you are trying to reduce the size of the logo's portlet you will also need to change the #p-logo a and #p-logo a:hover rules. The default setting for these is:

#p-logo a,
#p-logo a:hover {
	display: block;
	height: 200px;
	width: 12.2em;
	background-repeat: no-repeat;
	background-position: 35% 50% !important;
	text-decoration: none;
}

如何改变地址栏的图标 (favicon)?[edit]

  • 把favicon.ico上传到你的服务器的根目录.
  • 或者编辑LocalSettings.php中的$wgFavicon,增加$wgFavicon = "$wgScriptPath/path/to/your/favicon.ico";.

参阅Manual:$wgFavicon获得更多细节.

提示: favicon 的大小应为16x16 / 32x32 像素.

Rewrite 规则[edit]

如果你有用URL重写规则从URL中移除"index.php",你也需要为.ico加个例外.把下面一行加入到.htaccess中:

RewriteRule .*\.ico$ - [L]

这个规则必须在index.php的规则之前.

注意区分大小写[edit]

记得favicon.ico的文件名全是小写("favicon.ico",而不是"Favicon.ico").大多数的服务器(例如类UNIX系统)可能找不到有大写的文件名.

如何定义导航栏?[edit]

使用Monobook皮肤的每一个页面左边是导航条,其内容由您的wiki上的MediaWiki:Sidebar 页面决定. 定制这些内容的相关信息,请参看Manual:Interface/Sidebar.

如何在每一个页面上放置一个消息(站点通告)?[edit]

MediaWiki:Sitenotice放置一些文本.内容会显示在所有的页面上方.

你也可以在MediaWiki:Anonnotice上放置一些文本,当用户未登录时会出现在页面的上方.

如何指定首页?[edit]

默认的首页名称为"首页".编辑MediaWiki:Mainpage来改变.有时边栏中的"首页"链接可能没有改变,这时需要编辑 MediaWiki:Sidebar.

如何改变首页的标题?[edit]

用移动页面选项移动首页即可.

通常你可能期望指定哪个页面是首页.

如何在首页隐藏标题?[edit]

MediaWiki默认没有隐藏首页标题的功能(参阅task T8129),你可以用CSS或者NoTitle extension完成.

将下面一行添加到你wiki上的MediaWiki:Common.css中:

body.mainpage.action-view h1.firstHeading, body.mainpage.action-submit h1.firstHeading { display: none; }

如果你的MediaWiki版本非常旧,或是你移动了首页却没更新MediaWiki:Mainpage,或是某些不支持这项设定的皮肤上,这可能无法工作

如果你的皮肤不是使用h1标签和firstHeading类选择器的话,你需要自行调整. If the skin uses a different element for the title than a h1 element with class firstHeading, you'll need to find the appropriate CSS selector to apply for that skin.

如何隐藏目录?[edit]

目录 (TOC) 会在大于四个标题的页面上显示,当然也有办法隐藏.

某个页面[edit]

把魔术字 __NOTOC__ 放在页面上.
所有页面
NoTOC扩展
或者
添加
.toc, #toc { display: none; }
MediaWiki:Common.css.
单个用户
用户可以把同样的规则添加到用户样式表中(例如 common.css).
MediaWiki版本:
1.22
Gerrit change 99430
参数设置中曾经有一个参数可以隐藏目录,这个功能在MediaWiki1.23中被移除了. (phab:T54813).

如何改变界面文字?[edit]

如何改变界面文字语言?[edit]

要改变默认的界面的语言,在LocalSettings.php改变$wgLanguageCode的值,例如:

$wgLanguageCode = "fr";

你也许需要绕过浏览器缓存来查看更改.

新的默认值会对没有更改过这项设置的用户生效.

Extension:UniversalLanguageSelector提供了一种让用户自行选择显示语言的方法,Extension:Translate可以让用户翻译wiki上的内容为其他语言.

旧版本的MediaWiki可能不会更改现有用户的设置,现有用户可能需要修改自己的参数设置.

要修改所有用户的默认设置,运行 userOptions.php 维护脚本. 下面的例子会把现有用户的默认语言由英文变为法文:

php userOptions.php language --old en --new fr

如何去除某个标签(例如"文章"或"编辑")?[edit]

请参阅: User:Subfader/Hide_page_tabs多获得些功能.

添加下一行到MediaWiki:Common.css中:

li#ca-edit { display: none; }

查看源代码来知道要移除的标签的选择器ID.

注意: 这个设置只会在Monobook(或其分支,例如Vector)皮肤上工作,它也不会阻止用户编辑,参阅Manual:User rights来获得阻止用户编辑的方法.

如何增加一个标签?[edit]

旧版本的MediaWiki可以通过Extension:DynamicTabs来实现 (也可以通过Manual:Hooks/SkinTemplateNavigation编写自己的扩展):

下面的实例会移除讨论标签并 添加一个回到首页的标签,假设它叫做extensions/AR-Tabs.php:

MediaWiki版本:
1.15
<?php
if( !defined( 'MEDIAWIKI' ) ){
	die( "This is not a valid access point.\n" );
}

$wgHooks['SkinTemplateContentActions'][] = 'replaceTabs';
function replaceTabs( $content_actions ) {  
	unset( $content_actions['talk'] ); // only this to remove an action
	$maintitle = Title::newFromText( wfMsgForContent( 'mainpage' ) );
	$main_action['main'] = array(
		'class' => false or 'selected', // if the tab should be highlighted
		'text' => wfMsg( 'sitetitle' ), // what the tab says
		'href' => $maintitle->getFullURL(), // where it links to
	);
	$content_actions = array_merge( $main_action, $content_actions ); // add a new action
	return true;
}
MediaWiki版本:
1.16
<?php
if( !defined( 'MEDIAWIKI' ) ){
	die( "This is not a valid access point.\n" );
}

$wgHooks['SkinTemplateNavigation'][] = 'replaceTabs';
function replaceTabs( $skin, &$links) {  
	unset( $links['namespaces']['talk'] ); // Remove the talk action
	$maintitle = Title::newFromText( wfMsgForContent( 'mainpage' ) );
	$links['namespaces']['main'] = array(
		'class' => false or 'selected', // if the tab should be highlighted
		'text' => wfMsg( 'sitetitle' ), // what the tab says
		'href' => $maintitle->getFullURL(), // where it links to
		'context' => 'main',
	);
	return true;
}

然后把下面一行添加到LocalSettings.php中:

require_once("extensions/AR-Tabs.php");

如何去除某个页面上的某个标签?[edit]

MediaWiki版本:
1.9

编辑MediaWiki:Common.css,下面的例子会移除首页上的讨论标签:

body.page-Main_Page li#ca-talk { display: none !important; }


也请参阅:Manual:Hide page tabs

去除所有页面上的某一个标签[edit]

MediaWiki版本:
1.9

编辑MediaWiki:Common.css,下面的例子会移除所有页面上的讨论标签:

#ca-talk { display:none!important; }

其他的标签id还有 #ca-history, #ca-viewsource, #ca-view (条目), #ca-nstab-main (首页), #ca-viewsource.

下拉菜单里的标签id有 #ca-watch, #ca-move, #ca-delete.


如何对匿名用户隐藏"编辑段落"链接?[edit]

改变$wgDefaultUserOptions 的值可以实现,

编辑LocalSettings.php,加入下面一行:

$wgDefaultUserOptions ['editsection'] = false;
另参阅如何阻止匿名用户编辑页面?

如果 $wgDisableAnonTalk为真,如何去除"关于此IP地址的讨论"按钮?[edit]

设置 $wgShowIPinHeader 为 false.

如何移除"登录/创建账户"链接?[edit]

LocalSettings.php添加下面的代码可以从个人工具栏中移除"登录/创建账户"链接:

$wgHooks['PersonalUrls'][] = 'lfRemoveLoginLink';
function lfRemoveLoginLink( &$personal_urls, $title ) {
	unset( $personal_urls['login'] );
	unset( $personal_urls['anonlogin'] );
	unset( $personal_urls['createaccount'] );
	return true;
}

如何限制某些操作和访问特殊页面?[edit]

注意: MediaWiki 不是为这种用法设计的!

Suppressing actions and special pages can be useful when you want to create the illusion of a static website via a particular URL or VirtualHost, but also have an 'internal' view that is a true wiki. i.e. if you have an inward facing 'view' of your wiki that users can edit, and an outward facing 'view' that should appear like a static website (no history, no discussion, etc., etc.).

After hiding all the appropriate links (参阅above), if you are using the Apache web server, you can disable actions and special pages using the following rewrite rules:

# Lock down the site (disable MediaWiki commands)

RewriteEngine On

#RewriteLog /tmp/rewrite.log

#RewriteLogLevel 9

## See http://www.mediawiki.org/wiki/Manual:Parameters_to_index.php#Actions

RewriteCond %{QUERY_STRING} (.*action=.*)
RewriteRule .* http://www.my.domain.com?

RewriteCond %{REQUEST_URI} !^/index.php/Special:Search
RewriteCond %{REQUEST_URI}  ^(.*Special:.*)
RewriteRule .* http://www.my.domain.com?

## Catch a trick...
RewriteCond %{QUERY_STRING} ^(.*Special:.*)
RewriteRule .* http://www.my.domain.com?

Above, a request for 'http://www.my.domain.com/wiki/Page_name?action=edit', for example, will be simply rewritten to 'http://www.my.domain.com'. Similarly any page in the Special namespace (with the exception of Special:Search) will be rewritten to 'http://www.my.domain.com'. Remember, this is only a hack, and isn't intended as a solution for a secure CMS.

Note that you will need to adjust the above rules to match your specific URL naming schema.

Other issues to consider when trying to lock down a site like this is the API and POST requests for the wiki content (rather than GET).

如何编辑系统消息?[edit]

Special:Allmessages包含系统消息的列表,可以编辑.

如何改变页脚?[edit]

参阅Manual:Footer and Manual:Configuration settings#Copyright

如何移除页脚中的"Powered by MediaWiki"图像?[edit]

编辑MediaWiki:Common.css:

#f-poweredbyico { display: none; }

对于Vector皮肤:

#footer-icon-poweredby { display: none; }

对于1.17版的Vector皮肤:

#footer-icon-poweredbyico { display: none; }

对于1.18版的Vector皮肤:

#footer-poweredbyico { display: none; }

在1.17版本中,可以把下面一行添加到LocalSettings.php中来完全移除Powered by MediaWiki图像:

unset( $wgFooterIcons['poweredby'] );

对于1.16及以前的版本,你需要使用hooks:

$wgHooks['SkinTemplateOutputPageBeforeExec'][] = 'lfRemovePoweredBy';
function lfRemovePoweredBy( $sk, &$tpl ) {
	unset( $this->data['poweredbyico'] );
	return true;
}

参阅$wgFooterIcons 获得关于自定页脚图标的更多信息..

如何自订签名消息(例如增加一个回复链接)?[edit]

编辑MediaWiki:Signature(用户) 或 MediaWiki:Signature-anon(匿名用户).

例如 [[{{ns:user}}:$1|$2]] ([[{{ns:user_talk}}:$1|talk]]) 会放置一个讨论页链接, [[{{ns:user}}:$1|$2]] ([{{fullurl:{{ns:user_talk}}:$1|action=edit&section=new}} Reply]) 会放置一个直接增加新段落的链接.

用户可以通过参数设置自定义自己的签名.

能改变标题吗,怎样做?[edit]

大部分你希望更改的内容可以在MediaWiki名字空间中找到,前往Special:AllMessages并搜索你希望更改的文字获得页面的位置,要编辑的话还需要管理员权限.

要改变在浏览器标题栏中显示的标题,编辑MediaWiki:Pagetitle.在最近的MediaWiki版本中,默认的设置为MediaWiki:Pagetitle is $1 - {{SITENAME}}.

记得在改变后清除你的浏览器缓存来查看改变.

MediaWiki能自动首字母大写$wgSitename吗?[edit]

可以,在LocalSettings.php中改变 $wgCapitalLinks 设置即可 .

如何在新窗口打开外部链接?[edit]

参阅Manual:Opening external links in a new window

我能阻止MediaWiki格式化文本吗?[edit]

用"<nowiki>"标记包围不希望格式化的文本即可.

例子:

svn co <nowiki>http://svn.example.com/myproject/</nowiki>

结果:
svn co http://svn.example.com/myproject/

如何强制用户先预览再提交编辑?[edit]

请参阅: Manual:Force previewExtension:ForcePreview

如何在编辑页面上增加更多按钮?[edit]

请参阅: Manual:Custom edit buttons

如何在编辑器中增加插入字符的链接?[edit]

安装并配置Extension:CharInsert.

如何在自己的wiki上使用维基百科的默认皮肤(Vector)?[edit]

MediaWiki版本:
1.16

Vector 推出于 1.16版本,在1.17版本中为默认皮肤. 参阅Manual:$wgDefaultSkin 来设置你wiki的默认皮肤.

MediaWiki版本:
1.15

安装Vector扩展来实现更多功能.


如何在显示打印版本时不显示外部链接?[edit]

将下面的代码添加到你的wiki上的MediaWiki:Print.css中:

#content a.external.text:after,
#content a.external.autonumber:after {
	content: none;
}

或者你希望在打印版本中为外部链接加下划线:

#content a.external {
    text-decoration: underline !important;
}

如何改变首页上的标签的名称?[edit]

编辑"MediaWiki:Mainpage-nstab".

记得清除缓存来查看结果.

基本使用[edit]

如何编辑页面?[edit]

参阅:MyLanguage/Help:Editing pages

如何创建一个页面?[edit]

有几个方法创建一个新页面:

  • 创建一个指向它的内部链接,然后点击它.
  • 转到你希望创建的页面,例如 http://www.example.com/index.php?title=New_page ,然后点击"创建" 或 "创建源代码" 链接.

在某些wiki上,失败的搜索中会包含创建页面的链接.

也请参阅:MyLanguage/Help:Starting a new page

能删除一个旧版本的页面吗?[edit]

旧版本会为了方便复查或回退更改而保留在数据库中,不过管理员可能会因为法律原因或为了减少数据库占用的空间而希望删除某些版本.

  • 管理员可以删除整个页面再回=恢复某些版本
  • Oversight (也称作HideRevision) 扩展可以用来去除指定的修订历史.(MediaWiki <1.16).
  • 新版的 MediaWikis (1.14+)中,可以启用RevisionDelete(修订版本删除)功能来允许有权限的用户从编辑历史中移除一个版本.
  • maintenance/deleteOldRevisions.php 维护脚本 可以进行大量删除修订版本.
也请参阅:Manual:Removing embarrassment

如何删除某个页面的某些版本?[edit]

请参阅: RevisionDelete

或者你可以删除整个页面再恢复你需要的版本.

有没有一个编辑教程?[edit]

这里和维基媒体计划上有些教程可以参考:

如何查看某个页面的打印版本?[edit]

MediaWiki内置了一套用于打印的css样式表,你可以在你的浏览器中打开打印预览窗口来查看.

或者你可以使用边栏的打印版本链接(如果启用了Collection扩展,则是打印/导出).

如何使用模板?[edit]

参阅Help:Templates

我能使用维基共享资源上的多媒体文件吗?[edit]

是的,鼓励你通过设置$wgUseInstantCommons来使用.

也请参阅:InstantCommons

如使用一个模板作为签名?[edit]

不建议在签名中使用模板(例如这样(User:Name/sig)的签名)或在签名中加入外部链接。服务器在处理签名模版和有外部链接的签名时需要运行额外的进程,而且当你改变外部链接页面时,所有你曾以该签名发言的讨论页都得更新缓存。这可见这些签名对服务器资源的影响。而且,当用户离开计划,无人管理的签名模板亦会成为破坏的目标。至于一般的文本签名,是和讨论页内容一同保存的,消耗的资源不会比注释多,更不用担心模板被破坏的问题。

要直接产生您签名模版里面的文字,而不是引用模板:

  1. 建立一个页面来包含你的签名(例如User:Example/sign)
  2. 打开参数设置,在参数设置的“您的昵称(签名时用)”字段,填入“{{subst:您的签名模版名称}}”,并且勾选“将签名视为维基文本(不自动生成链接)”。
  3. 保存你的参数设置.

如何加入沙盒功能?[edit]

大多数情况下,沙盒是一个任何用户可以编辑的页面.这只是个你可以自由决定的普通页面,MediaWiki并没有这种核心功能.

你也许注意到维基百科上的沙盒像是自动清空的,但这不完全对.清空沙盒是由用户(或是机器人)定时完成的.


如何在个人工具栏(右上角)加入一个沙盒链接?[edit]

如何运行一个多语言wiki?[edit]

要让你的wiki提供工具进行翻译和自定义界面文字,可以使用翻译扩展,文档在这.

导入[edit]

从MediaWiki XML 转储中导入[edit]

参阅Manual:Importing XML dumps

从其他类型文件中导入[edit]

有多种可以帮助将HTML或者其他标记语言转化成MediaWiki标记的工具.

开发者和系统管理员工具
用户工具
指南

MediaWiki自动导入脚本[edit]

Taken from wiki_import - MediaWiki auto import script:

描述[edit]

The script is designed to import a whole folder of files into MediaWiki, with the folder directory tree mapped as wiki category hierarchy.

功能[edit]

  • economic, build wiki site from existing knowledge base collection without "double-entry"
  • persistent, map folder directory tree as wiki category hierarchy
  • sophisticated, import/handle all well-known file types automatically
  • complete, cover every applicable scenario, even the case when you need to control access to individual wiki pages
  • versatile, highly customizable

快速参考[edit]

wiki_import.sh $ $Revision: 1.1 $

mediawiki automatic file import script

Usage: wiki_import.sh [OPTIONS]...

The script is designed to import a whole folder of files into mediawiki, with the folder directory tree mapped as wiki category hierarchy.

The specification of the file-to-import is passed from standard input.

Options:

 -s, --sect=n     the root category section of the wiki
                    of the imported article (mandatory)
 -1, --header     include standard header (category hierarchy path & notice)
 -l, --link       link to actual file on the web site
 -f, --footer     include standard footer (article category)
 -R, --res[=p]    add restricted tag in the footer
                    as '{{<Res Param|Root Category> Restricted}}'  
                    (default=`$_opt_sect')

Configuration Options:

 -p, --php=fn     mediawiki import php script specification
 -r, --root=n     the root category name for the whole wiki site
 -m, --max=n      max_allowed_packet for mysqld to import
 -u, --user=n     wiki user used for the import
 -a, --arch=p     the root url that linked-to archive files based on

Examples:

 echo ./path/to/file.ext | wiki_import.sh -1 -l -f -s 'Customer Support' -R 

For the rest of details, check out wiki_import.

从其他网站(例如维基百科)导入的模板不工作[edit]

你需要安装一些在导出源wiki上使用的扩展,比如ParserFunctionsCite.同时确定你复制了需要的CSSJavaScript.

进一步配置[edit]

如何让多个wiki使用一个凭据登录?[edit]

如果你正在分割一个wiki为多个,可以使用$wgSharedDB$wgSharedTables来让不同的wiki使用同一个用户数据库.你也可以共享那些不依赖于未共享的表或是特定于某个子wiki的表,参阅Manual:Shared database获得示例和更多信息.

如何允许HTML标签?[edit]

参阅Manual:$wgRawHtml ,Manual:$wgGroupPermissionsManual:Preventing access.

小心! 小心: 此功能容易被破坏者滥用

也请参阅Extension:SecureHTMLExtension:HTMLets,这些方法可以让你更安全的插入HTML.

如何为MediaWiki增加新功能或是修复bug?[edit]

改进 (换句话说, 黑掉)MediaWiki的几个基本步骤是:

  • 安装Git
  • 从Git克隆MediaWiki源码.
  • 在你的电脑上运行web服务器,PHP和数据库服务器 (设置它们让你窝火? 遇到问题就求救呗~)
  • 在你的电脑上运行MediaWiki (同样让你窝火? 方法同上)
  • 修复问题或是增加你期望的新功能,没啥想法?从 "修复那些恼人的bug"开始呗.
  • 编辑源代码和相关的文件
  • 接着看Gerrit/Tutorial

如何运行一个机器人?[edit]

参阅Manual:Bots

或许可以试试Pywikibot框架.

如何设置 noindex nofollow[edit]

在LocalSettings.php中添加 $wgNoFollowLinks = false;.

如何设置一个小型wiki 农场?[edit]

请参阅: Manual:Wiki family

如何添加meta标签?[edit]

OutputPage类包含一个用来添加meta标签的addMeta方法.

To add further Meta tags just add further lines as last lines of the function addMetaTags() like:

$out->addMeta ( 'description', 'This is a meta description.' );

或者使用像Extension:WikiSEO一类的扩展.

为什么...?[edit]

…帮助名字空间是空的?[edit]

现在帮助名字空间默认是空的.是在你的wiki上还是MediaWiki.org上提供帮助由你决定.

现在我们还没有一个清除明了,国际化而且自由的文档.不过希望复制一些帮助信息到你的网站?没问题!Help:Contents中的内容在基于MediaWiki搭建的网站上应该都可以使用,而且没有授权问题.参阅Project:PD help,更多的帮助可以在元维基上的"MediaWiki Handbook"中找到.

…升级后某些图像无法显示?[edit]

有些用户报告说在升级后无法显示某些图片,它们被服务器报告说"MIME类型无效"或"可能有害".

可以在终端运行maintenance/rebuildImages.php 来在数据库中设置新的MIME类型.

…png格式的图片没有缩略图?[edit]

有时升级了PHP版本以后MimeMagic.php函数的工作方式发生了变化,或者内置函数mime_content_type无法识别PNG格式,试着在web上搜索mime_content_type png获得关于如何修复它们的信息.

参阅here 获得更多信息.

…搜索一个wiki内容中的关键字却没有结果?[edit]

By default, MediaWiki uses MyISAM's fulltext matching functionality to allow searching page content. The default settings for this mean that words of less than four characters won't be indexed, so will be ignored in searches with older versions of MediaWiki.

MediaWiki 1.13 and earlier are unable to work around this; you must either change MySQL's configuration to index shorter words, or upgrade to a more recent version of MediaWiki.

Note that some particular words may still not be indexed if they are in MySQL's default stopword list.

…不能下载MediaWiki1.27?[edit]

MediaWiki 1.42 是在开发中的版本,如果你想尝试的话,你可以从Git下载,或者通过 {{mwsnapshots-link}} 下载最新的Tarball.

…某个在维基百科中的功能没法在我的wiki上工作?[edit]

维基百科(或是Wikimedia的其他网站)运行的是MediaWiki的开发版本(现在是1.42.0-wmf.22 (bd76262)),这意味着某些功能可能与现在的稳定版并不一致.


…在Fedora上设置好权限后却得到了一个403错误?[edit]

Fedora Core 默认启用SELinux.参阅这个页面获得关于设置SELinux的更多信息.

…自动注销了?[edit]

这个问题和Cookie或是会话有关,例如PHP中的 session.save_path [1]. 参阅登录问题?获得解决方案.

…我的wiki在Sourceforge上不工作?[edit]

参阅Manual:Installing MediaWiki on SourceForge.net.

…留着账户是个好主意?[edit]

At many times you just want to remove a user account out of the wiki either because it belonged to a spammer account or you just feel like it. The appropriate choice is to block the account or rename it if needed. Here is why:

Do I just remove his row from the User table?

Rob Church posted the following regarding this issue on the mediawiki-l mailing list:

"If the user has made edits, then removing rows from the user table cause theoretical loss of referential integrity. Now, to be honest with you, I can't think of any conditions where this would cause an actual problem; "undefined behaviour" is the phrase we use.

What I'd suggest doing, to be on the safe side, is running a couple of quick updates against the database:

UPDATE revision SET rev_user = 0 WHERE rev_user = <current_user_id>
UPDATE archive SET ar_user = 0 WHERE ar_user = <current_user_id>

What this will do is cause MediaWiki to treat the revisions as having been made anonymously when generating things like page histories, which should eliminate any problems caused by these routines attempting to check user details from other tables.

If the user has caused log entries, i.e. rows in the logging table, or uploaded images, then the situation becomes trickier, as you'll have to start mopping up all the rows everywhere and it could become a bit of a mess, so if the user's done anything other than edit, I would strongly recommend just blocking them indefinitely.

If the username is offensive or undesirable, then you could consider renaming it using the RenameUser extension."

Another option is to give Admins the 'hideuser' right, and indefinitely block the user with the Hide username from edits and lists option selected.

Extension:UserMerge is also useful.

反垃圾相关[edit]

到那里获得垃圾黑名单?[edit]

spam blacklist能够从Git中获取,参阅README扩展的页面获得详细信息.

如何用$wgSpamRegex阻止多个字符串?[edit]

尽管$wgSpamRegex在过滤页面内容方面非常强大,在正则表达式里添加多个项目可能把事情弄得很糟糕。

请考虑使用下面的方法:

$wgSpamRegexLines[] = 'display\s*:\s*none';
$wgSpamRegexLines[] = 'overflow\s*:\s*auto';
[...]
$wgSpamRegex = '/(' . implode( '|', $wgSpamRegexLines ) . ')/i';

这段代码范例很方便的在正则表达式里添加额外的字符串而无须每次都费时费力再做调整。这段代码也展示其他两个很流行的屏蔽一些最常见的垃圾信息攻击的过滤器。

也请参阅: Extension:SpamRegex

有没有其他的方法对抗垃圾骚扰?[edit]

参阅Manual:Combating spam 来了解像Captcha一类的反垃圾骚扰的方法.

反破坏相关[edit]

参阅Manual:Combating vandalism 获得对抗破坏的一些提示

现在在哪?[edit]

到哪里提交bug报告和功能请求?[edit]

Phabricator提交Bug报告和功能请求. 参阅How to report a bug.

发生了一个奇怪的错误,我该怎么办?[edit]

我尝试过了,但是没用.[edit]

我遇到了一个问题,我发现FAQ有解决方案,也照着FAQ做了,但是没用!!!

十有八九是你没清除缓存,有一个非常简单的方法可以访问一个未缓存的页面.在你的地址栏上?title=的后面随便输入个标题,按下Enter键,看看会不会遇到相同的问题.

MediaWiki使用服务器端和客户端缓存,所以简单清除客户端缓存并不够.刚刚提到的清除缓存一节有指导.

或许你该检查别的:

  • 你编辑的是正确的文件吗?试着在你编辑的文件里乱写一通,有什么坏掉了吗?
    • phpinfo.php(一个只包含 <?php phpinfo() ?> 的文件)是调试的好工具,把它上传到你的服务器上,打开它,查找php.ini中指定的文件位置.
  • 你有把设置放在正确的部分吗?你有在php.ini中创建重复的目录吗?记得把新的设置加到LocalSettings.php的最下面(而不是最上面!)
  • 如果你有创建 .htaccess, 请确定AllowOverrides打开了吗? 可以问问你的主机商.

有个没提到的问题,怎么办?[edit]

如果你已经仔细研究了上面的常见问题并且还是找不到答案的话,请尝试以下方法:

运气不好,没有得到帮助咋办?[edit]

推荐阅读[edit]

参考[edit]