Manual:LocalSettings.php/zh

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

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

(If you are using Vagrant, see also MediaWiki-Vagrant#MediaWiki_settings.)

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

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

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

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

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

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

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

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

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

Include path
The $IP (include path) variable holds the local file path to the base installation of your wiki. Since MediaWiki 1.17, MediaWiki is setting $IP automatically - setting it manually in  is no longer needed. It will default to the current working directory automatically and can be used without the need to manually define it.

The DefaultSettings.php file gets loaded from the directory designated by the IP variable.

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

Declensions of site name
Some translations of interface are ready for inflection of site name. You can set proper forms of word in variables ' (for example please refer to the ' documentation page).

网站语言
 controls the language of your wiki's interface. While users can switch the language they see in their preferences, this variable sets the default language that all anonymous users and most registered users see.

脚本路径
 is the URL path prefix to access the main MediaWiki script that is the central acting piece of code of MediaWiki. This setting should correspond to the Apache settings, especially if you are using Apache's rewrite rules.

服务器名称
 can be used optionally to overwrite the automatic detection. When the wiki is accessed from either the localhost where it runs, from an intranet or from the internet, e-mail notifications and a few other computed messages would be usually delivered with the different URLs. Using  overwrites the detection and the server name will be constant.

If www.example.com is the server address of your wiki as seen from the internet, add a line such as

The magic word variable  can be used on wiki pages; it equals the value of  ; however, on a wiki, such as those in the WikiMedia family, where relative urls are used, it will not fully expand, for example here it displays, which can neither be clicked nor copy-pasted into the address bar as it is.

脚本名称
 is the name of the main (index) MediaWiki PHP script, named  by default. Changing the script name is probably not a good idea. However, if you feel the urge to do so, this is the place to make your changes. Make sure you know what you are doing.

重定向脚本名称
 specifies the URL path to the redirect script which handles redirects in MediaWiki. This setting is similar to wgScript as you can configure the exact name of the script. As mentioned above, this is probably not a good idea unless you really know what you are doing.

文章路径
 is the path to use when accessing a page in MediaWiki. The path should contain the path to the main script (usually making use of ) and use the   placeholder for the article name.

If you are using Apache rewrite rules to create pretty and short URLs, you probably need to adjust  to address the right path. Note that wgArticlePath is used to construct URLs from within MediaWiki. If you make a mistake here, internal links will show up incorrectly while you still may be able to access the main page by specifying the correct URL manually. See Manual:Short URL for more information on URL configuration.

典型值为:

Stylesheet location
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.

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

 is the e-mail address where e-mail 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.

用户权限
 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 Help:User rights 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 trouble-shooting.

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.

Note: After changing the language code, you will need to run a PHP script to make it work. In a terminal window, change to your wiki directory, change to the  folder, and enter. On Windows, the PHP folder might not be in your  environment variable and you'll have to prefix php with the path to the program.

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.
 * Note: If  is non-empty, the link in the copyright/license notice will link to that page on your site. If   is empty then the copyright/license notice will link to   instead.

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 $wgNamespaceAliases 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 Custom namespaces 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.
 * Extension:Configure provides a way to set configuration settings from a special page.
 * Manual:Securing database passwords - a guide to securing your database passwords and  file.