Manual:LocalSettings.php/zh

 文件提供了MediaWiki安装的基本配置设置（基于 文件）. 您应该花些时间查看文件中的设置. 该文件一般是由基于Web的MediaWiki安装程序生成，但您可以调整参数，与Apache配合使用. 若将MediaWiki作为维基农场配置，可能会使用一个被称为 的文件.

服务器上的位置
文件不是一个Wiki页面且您不能够通过网页浏览器访问它.

相反，它是服务器文件系统中的一个文件. 它的内容是在wiki的初始设置过程中生成的，生成的文件必须手动复制到服务器上. 此文件必须位于您安装MediaWiki的目录中，与文件夹 、 和文件 在同一级目录. 若该文件不在这里，这个Wiki将完全不会工作；若这个Wiki在工作，那么该文件就在这里. 如果您不知道这个文件在哪里，您可以在终端窗口中输入例如命令来查找它，例如： find / -iname LocalSettings.php -print.

（如果你正在使用 Vagrant，另见 MediaWiki-Vagrant#MediaWiki_settings. ）

安全
通常包含敏感数据比如数据库登录信息. 这个数据永远不应向公众透露. 由于服务器上某处存在安全漏洞，可能会发生其他用户可以查看文件内容. 为了提高数据的安全性，您应该相应地为此文件设置UNIX权限：网络服务器用户必须能够访问这个文件. 若与拥有该文件的帐户相同，则可以将权限设置为600. 有时网络服务器用户不是这个文件的所有者，而在所有者的UNIX用户组中. 这时权限应被设置为640. 为了提高安全性，您应尽可能使用最小权限.

此外，您可以创建一个仅在Wiki上使用MySQL用户并在 中提供相关的凭据. 此外，您还可以配置您的MySQL服务器仅接受来自于本地的连接，这将降低从外部访问使凭据泄露的情况.

Also see for a method to move the sensitive parts of   to a different file in a different directory.

文件内容
当您在编辑 文件时，请确保以正确的编码下保存. 您应该使用“ANSI as UTF-8”编码（即无字节顺序标记的UTF-8编码）.

文件中包含了PHP代码，主要是变量和其值的定义. 更改设置通常意味着更改PHP变量的值. 将文件保存到服务器后，您的更改将立即生效：不需要手动“重启”任何东西. 尽管在某些情况下，您可能需要清除浏览器的缓存才能看到您所做的更改.

许多默认值在 中被设定，您不应该去改动它. 如果您要更改的变量未在 中提及，请从 中复制相应的行到 中并做些相应的更改. '''在 中，您可以在末尾添加新行. '''

在该文件中，将有几行内容指向扩展，例如：“ ”这几行允许在Wiki中启用相应的扩展. 这些扩展可能需要在 中设定更多变量的值， 有关进一步的说明，请参阅相应扩展的文档.

像MediaWiki中的大多数PHP文件一样， 文件并不以关闭的PHP标签结束. 这样可以防止管理员意外地在此标签之后添加新信息. PHP没有关闭标签工作正常.

倘若您有一个在维基农场上的MediaWiki，您可能并没有编辑（可能也没有阅读的权限） 文件的权限（例如参见）. Wiki Farm的公司可能愿意或不愿做出您所期望的更改. 也许他们希望在维基农场的所有维基上保持多数相同的配置.

可用参数概览
请参阅配置设置索引以及设置文件中包含的说明，以获取所有相关变量的帮助. 以下列出了最重要的变量以及多数需要的功能的简短列表.

安装路径
$IP（安装路径）变量保存了你的 wiki 基本安装的本地文件路径. 从 MediaWiki 1.18 开始，系统会自动设置 $IP. 不再需要在  中手动设置. 将默认为当前工作目录，无需手动定义即可使用. Attempting to set  (or  ) in   may produce unexpected results.

文件从 IP 变量指定的目录中加载.

网站名称
保存您安装wiki时设置的名称. 这个名字在整个系统中被多次包含如通过MediaWiki:Pagetitle. 例如，维基百科的标语“维基百科，自由的百科全书”就使用了这个设置.

网站名称的变格
界面的一些翻译已准备好用于站点名称的变化. 您可以在变量 ' 中设置正确的单词形式（例如，请参阅 ' 文档页面）.

网站语言
$LanguageCode用于控制您wiki的界面语言. 尽管用户可以通过在参数设置中改变他们看到的语言，但此变量设置了所有匿名用户和大多数注册用户看到的默认语言.

脚本路径
 是访问主要 MediaWiki 脚本的 URL 路径前缀，该脚本是 MediaWiki 的核心代理代码. 这一设置应该与Apache的设置相符合，尤其是如果您使用了Apache的URL重写规则.

服务器名称
 包含服务器的基本 URL，包括协议，但没有尾部斜杠，也没有子目录（如果有）. 当 wiki 从它运行的本地主机、Intranet 或 Internet 访问时，电子邮件通知和一些其他计算消息通常会通过不同的 URL 传送.

从 MediaWiki 1.34 开始， 必须设置为 LocalSettings.php. 在此之前，MediaWiki 尝试自动检测服务器的名称， 是可选的，以覆盖自动检测.

如果您wiki服务器在互联网上的地址是www.example.com ，那么请加入类似如下的一行：

magic word 变量  可用于维基页面； 它等于   的值； 然而，在维基媒体系列中，使用相对网址的维基，它不会完全展开，例如这里显示，既不能点击也不能复制粘贴到地址栏 照原样.

You can also use a protocol relative URL as shown below. When using a protocol relative URL, be sure to set. is needed for some places in the code where an origin with a protocol and hostname is needed.

脚本名称
 是主要（索引）MediaWiki PHP 脚本的名称，默认名为. 更改脚本名称可能不是一个好主意. 但是，如果您有这样做的冲动，那么这里就是您进行更改的地方. 确保你知道你在做什么.

文章路径
 是访问 MediaWiki 页面时使用的路径. 该路径应包含主脚本的路径（通常使用 ）并使用   占位符作为文章名称.

如果您使用 Apache 重写规则来创建漂亮且简短的 URL，您可能需要调整  以找到正确的路径. 请注意， wgArticlePath 用于从 MediaWiki 中构建 URL. 如果您在这里犯了错误，内部链接将不正确显示，而您仍然可以通过手动指定正确的 URL 来访问主页. 有关 URL 配置的更多信息，请参阅 Manual:Short URL.

典型值为:

样式表位置
Use  to set the URL path to the place where the stylesheets (CSS) for the MediaWiki installation are located.  should point the same place, but note that this is a local file system path for use in internal scripts accessing the file system.

上传位置
The upload directory is the place where files uploaded by the users are stored. ' specifies the URL path, ' points to the local file system path.

标志
 specifies which graphical logo is displayed in the top left corner of all mediawiki pages. These steps replace the default logo in the /wiki/skins/common/images/ directory, replacing /wiki with the path to the directory where you installed the MediaWiki software.

First, copy whatever logo you want into the /wiki/skins/common/images/ directory (replacing /wiki with the path to the directory where you installed the MediaWiki software).

Next, try to find the line that looks like this in :

If there's no such line, you can copy and paste the line above at the end of the file.

Then, modify that line to point to your logo. The logo must be web accessible. The value of this variable is passed to the web browser, which uses it to fetch the logo. If in doubt, a good way to pick what to put here is navigate to the logo in your web browser (for example, this wiki the url of the logo is http://upload.wikimedia.org/wikipedia/mediawiki/b/bc/Wiki.png ), and put the full url as the value of this variable.

Some people just replace the skins/common/images/wiki.png file with their logo. This is not recommended, as the customized logo would be overwritten on upgrade.

MediaWiki 1.35 introduced , which allows multiple versions of the same logo. An example of using multiple logos is shown below.

联络信息
 is the email address of the user to contact if something goes wrong. This email address is used to send internal bug reports to. As an administrator, you want to include your email address here.

 is the email address where email gets sent from, when passwords are sent out to users who have forgotten their passwords. Choose an address people can reply to in case of trouble or confusion.

数据库设置
MediaWiki needs access to the database (currently either MySQL or PostgreSQL) to store pages, modifications, user information, and a lot more things.

 contains the hostname where the database is hosted on. In most cases this will be just "localhost" as the database is run on the same system, but for distributed installations, you need to fill in the fully qualified domain name of the computer running the database.

 is the database name of the database to be used by MediaWiki. A single MySQL or PostgreSQL installation can store more than one database and you can even run many MediaWiki installations on a single server. Make sure you have stated the correct database name here and use different database names for different wiki installations on the same database server.

' and ' contain the login name and password to be used by MediaWiki to access the database. Make sure the specified user has the proper access rights to be able to manipulate the wiki's table on the database server.

Also see for a method to move the sensitive parts of   to a different file in a different directory.

用户权限
 is an associative array, controlling permissions for creating and editing pages for your different user groups. In this array, custom permission levels can be created, and permission levels for the different user groups can be set. See for more information about the different permissions and user groups available.

Force capital links
By default, no page name can start with a lowercase Roman letter: in an attempt to do so the first letter is converted to uppercase; if a link target, included page, image or category is specified with a name starting with a lowercase letter, the actual target etc. is the page starting with the corresponding capital.

Alternatively page names can start with a lowercase letter, in addition to the possibilities of starting with a capital, a digit, etc. For that you must adjust . Setting it to false allows lowercase characters, true chooses the default behavior.

启用子页面
In, subpages are enabled on a per-namespace basis using . For example, to enable subpages in the main namespace:

文件上传
Before users are allowed to upload files to the MediaWiki system, you have to enable that feature. Make sure the Upload Directory is properly configured and writeable by the Apache web server process. Then set  to true to allow uploading in the web user interface.

i.e. Here's some example code from includes/DefaultSettings.php to put in :

If you want to be able to resize images on the fly to support thumbnails, MediaWiki needs a working ImageMagick installation. Set  to true once you have installed and tested ImageMagick on your system. Make sure ' points to the proper location of the  command of your installation, that the command is executable by the web server process, and ' is large enough. See for detailed information and troubleshooting.

Also, you may want to modify the list of accepted extensions, which is stored within :

In case ImageMagick outputs an error message similar to the following:
 * Fatal error: mime_magic could not be initialized, magic file is not available in includes/MimeMagic.php on line 506

then try adding the following line to :

= "file -bi";

跨wiki支持
InterWiki support is built into MediaWiki but you need to configure the prefix to be used for your internal links. This prefix is usually the same as, but in case you need to change that, you set the variable to the preferred name.

用户界面语言
MediaWiki allows for a variety of localized user interfaces languages instead of the English default. If you want to run your wiki in a non-English language, set the variable to the proper language code (e.g. "de" for German, "es" for Spanish, etc.)

You may use any of the languages with a file in the directory. E.g. if you find, then you can use   for Spanish. Do not use  with a capital letter. Although it seems to work, not all texts are translated.

Not all languages are supported. See here for a list of the localisation statistics of. See translatewiki.net for the statistics per released version.

设置网站的版权

 *  is the page on the wiki that covers the copyrights that it falls under. Usually, this will be Project:Copyrights.
 *  is the page describing full details of your license. (For the GNU FDL, for example, this would be .)
 *  is the text in the footer that follows "Content is available under". It will be linked to the page specified in.
 *  is the URL of the image placed at the left of the footer.

To modify the copyright statements of the site, add something like this to :

Afterwards, edit MediaWiki:Copyright to provide an appropriate message, using  to indicate the position where the link to your copyright page will be.

Example: setting a Creative Commons license

To set a Creative Commons license do the following:


 * Choose your license: http://creativecommons.org/choose/
 * Examine the returned HTML code, e.g.:


 * For  enter the href info from the first anchor:
 * For  enter the text the second anchor links from (add the "a" to the Wiki variable for a more grammatically correct version)
 * For  enter the src info from the img link in the first anchor. You want to copy the badge to your own site instead of using the one from the Creative Commons site.
 * For using RDF metadata about copyright add one or both of the following lines to your :

自定义名字空间
By declaring ', and modifying ', and ', extra namespaces can be added to a MediaWiki installation; and by declaring the ' array namespace aliases can be added. Take heed not to have any pages already titled in that namespace, for instance if you had a page called "Technical:Support" and you created the Technical: namespace, then that page would not only be lost, but you cannot remove it from Special:Allpages. To fix this delete the namespace, move "Technical:Support" to "Support" in mainspace, delete the redirect, reinsert the namespace, and move it back to "Technical:Support". See for more information as to how to do so.

皮肤
站点的默认皮肤可以通过 进行修改.

参见

 * source code, which generates the inital contents of  during installation.
 * Wiki families can share the same.
 * - a guide to securing your database passwords and  file.