Revision 551203 of "Manual:LocalSettings.php/zh-cn" on mediawikiwiki{{MW file|LocalSettings.php|NotInGit=安装时创建}}
本文件(基于 <code>'''DefaultSettings.php'''</code> 文件)是安装[[MediaWiki]]时创建的 [[Manual:Configuration settings|配置]] 。安装后需要检查此文件。 MediaWiki 的Web安装程序会自动生成这个文件,但是某些情况下需要调整一些参数配置,例如根据Apache的参数调整链接的模式.
更改配置一般是更改 [[w:PHP|PHP]] 变量。在继续之前请确保您熟悉PHP语法。一个最重要的规则是:创建和使用PHP变量必须以“$”开头;大多数变量仅仅简单的设置<code>true</code> 或者<code>false</code>。
更改在保存文件后会立即生效,没有必要手工重新启动。有时在更改配置后需要清除浏览器的缓存才能看到变化。
''不必修改''<tt>在/DefaultSettings.php</tt>中的''默认值'', 如果你想修改的配置项不在<tt>LocalSettings.php</tt>中, 将配置项从<tt>DefaultSettings</tt> 拷贝出来编辑即可。 你可以将新的配置添加到 <tt>LocalSettings.php</tt> 末尾,但是所有你添加的配置必须在 '<tt>require_once( "includes/DefaultSettings.php" );</tt>' 之后。
Within the file, there can also be several lines such as '<tt>require_once( "extensions/''extension''.php" );</tt>', which link to other [[Extension:Contents|extensions]] enabled on the wiki. Those extensions may require setting the values of more variables in <tt>LocalSettings.php</tt>; check the extension's documentation for further instructions. A list of extensions is available at [[Extension Matrix]].
:{{caution}}
:Do not place extensions before the <tt>require_once( "includes/DefaultSettings.php" );</tt> line; that will blank the extension setup function arrays, causing no extensions to be installed, and probably making your wiki inaccessible.
Your version of <tt>LocalSettings.php</tt> may not end with a closing PHP tag of '''<tt>?></tt>'''. This is done on purpose, as it prevents people from accidentally adding new information ''after'' this tag. PHP will function just fine without a closing tag.
See the [[Manual:Configuration settings|configuration settings index]] and the comments included in the settings files for help on what all the variables do. A short listing of the most important variables, as well as the most requested features, is listed below.
If you have a wiki on a MediaWiki [[w:wiki farm|wiki farm]] you may not have write-access (perhaps not even read-access) to the file LocalSettings.php (see e.g.[http://www.wikia.com/wiki/Forum:LocalSettings.php%3F]). The wiki farm company may or may not be willing to make changes you desire. Perhaps it wants to keep most settings the same on all wikis of the wiki farm.
==基础配置==
===本地路径===
'''[[Manual:$IP|$IP]]''' 变量存放着安装wiki站点的本地路径。注意不要在最后添加反斜线。DefaultSettings.php的读取路径会受到这个变量的影响。
===网站名称===
'''[[Manual:$wgSitename|$wgSitename]]'''变量存放wiki网站的名称(utf-8格式)。这个名称在系统中被多次引用。
===网站语言===
'''[[Manual:$wgLanguageCode|$wgLanguageCode]]''' 变量控制界面语言。用户可以通过设置[[Special:Preferences|参数设置]]来更改其看到系统的语言,这个变量是匿名用户和大部分注册用户的默认配置。
===Declination of site name===
Some translations of interface are ready for inflection of site name. You can set proper forms of word in variables '''[[Manual:$wgGrammarForms|$wgGrammarForms]]'''.
===Script path===
'''[[Manual:$wgScriptPath|$wgScriptPath]]''' 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 configuration|Apache settings]], especially if you are using Apache's [[w:Rewrite_engine|rewrite]] rules.
===Server name===
'''[[Manual:$wgServer|$wgServer]]''' 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 <code>$wgServer</code> 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
<source lang="php">$wgServer = 'http://www.example.com';</source>
The [[m:Help:Magic words#Page names and related info|magic word]] variable <code><nowiki>{{SERVER}}</nowiki></code> can be used on wiki pages; it equals the value of <code>$wgServer</code>; 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 {{SERVER}}, which can neither be clicked nor copy-pasted into the address bar as it is.
===Script name===
'''[[Manual:$wgScript|$wgScript]]''' is the name of the main (index) MediaWiki PHP script, named <tt>index.php</tt> 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.
===Redirect script name===
The '''[[Manual:$wgRedirectScript|$wgRedirectScript]]''' variable 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.
===Article path===
'''[[Manual:$wgArticlePath|$wgArticlePath]]''' 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 <code>$wgScript</code>) and use the <tt>$1</tt> placeholder for the article name.
If you are using Apache rewrite rules to create pretty and short URLs, you probably need to adjust <code>$wgArticlePath</code> 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.
Typical values are:
{| class="prettytable"
| class="hl2" style="text-align:left;" | "<tt>$wgScript/$1</tt>"
| class="hl1" style="text-align:left;" | pass the article name with separator "/"
|-
| class="hl2" style="text-align:left;" | "<tt>$wgScript?title=$1</tt>"
| class="hl1" style="text-align:left;" | pass the article name as a parameter (old style)
|-
| class="hl2" style="text-align:left;" | "<tt>mypath/$1</tt>"
| class="hl1" style="text-align:left;" | custom path. Use Apache rewrite rules to convert "mypath" to the proper path accessing the main script
|}
===Stylesheet location===
Use the '''[[Manual:$wgStylePath|$wgStylePath]]''' variable to set the URL path to the place where the stylesheets (CSS) for the MediaWiki installation are located. The '''[[Manual:$wgStyleDirectory|$wgStyleDirectory]]''' variable should point the same place, but note that this is a local file system path for use in internal scripts accessing the file system.
===Upload location===
The upload directory is the place where files uploaded by the users are stored. The '''[[Manual:$wgUploadPath|$wgUploadPath]]''' variable specifies the URL path, the '''[[Manual:$wgUploadDirectory|$wgUploadDirectory]]''' points to the local file system path.
===Logo===
The '''[[Manual:$wgLogo|$wgLogo]]''' variable specifies which graphical logo is displayed in the top left corner of all mediawiki pages.
Add the following two lines to <code>LocalSettings.php</code> (below the "require" statements):
<source lang="php">
$wgStylePath = "/wiki/skins/";
$wgLogo = "{$wgStylePath}/common/images/wiki.png";
</source>
This replaces the default logo in the /wiki/skins/common/images/ directory.
Another option is to direct the <code>$wgStylePath</code> variable to the Upload Directory to be able to exchange the logo by updating uploaded files.
<code>[[Manual:$wgStylePath|$wgStylePath]]</code> is usually <code>YOUR_WIKI_FOLDER/wiki/skins</code>.
*Note that in the example given, the <code>$wgLogo</code> points to <code>/wiki/skins/common/images/wiki.png</code> with the first part being defined by <code>$wgStylePath</code>. Make sure you have both correct, or <code>$wgLogo</code> will not point to where you think it's pointing.
===Contact info===
The '''[[Manual:$wgEmergencyContact|$wgEmergencyContact]]''' variable is the e-mail address of the user to contact when things happen. This e-mail address is used to send internal bug reports to. As an administrator, you want to include your e-mail address here.
The '''[[Manual:$wgPasswordSender|$wgPasswordSender]]''' variable 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.
==Database settings==
MediaWiki needs access to the database (currently either [[:w:MySQL|MySQL]] or [[:w:PostgreSQL|PostgreSQL]]) to store pages, modifications, user information, and a lot more things.
The '''[[Manual:$wgDBserver|$wgDBserver]]''' 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.
'''[[Manual:$wgDBname|$wgDBname]]''' 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.
The '''[[Manual:$wgDBuser|$wgDBuser]]''' and '''[[Manual:$wgDBpassword|$wgDBpassword]]''' variables 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.
===Security===
Keep in mind that the LocalSettings.php [[w:File system permissions|permissions]] should not allow other users to view this file as it contains security-related data, including your database user password. [[w:chmod|chmod]] 700 or otherwise set the permissions to something that provides security from public access. Additionally, the database user only needs to have SELECT, INSERT, UPDATE and DELETE permissions for the database. See also [[Manual:AdminSettings.php#Security|AdminSettings.php]] which is a MySql user that has superuser database permissions to run the maintenance scripts.
===User rights===
The '''[[Manual:$wgGroupPermissions|$wgGroupPermissions]]''' 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 [[:w:Latin alphabet|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 the '''[[Manual:$wgCapitalLinks|$wgCapitalLinks]]''' variable. Setting it to '''false''' allows lowercase characters, '''true''' chooses the default behaviour.
===Enabling subpages===
Subpages are enabled on a per-namespace basis using the '''[[Manual:$wgNamespacesWithSubpages|$wgNamespacesWithSubpages]]''' variable. For example, to enable subpages in the main namespace:
<source lang="php">$wgNamespacesWithSubpages[NS_MAIN] = 1;</source>
===Image uploads===
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 the '''[[Manual:$wgEnableUploads|$wgEnableUploads]]''' variable to '''true''' to allow uploading in the web user interface.
i.e. Here's some example code from ''includes/DefaultSettings.php'' to put in ''LocalSettings.php''.
<source lang="php">
$wgUploadPath = "$wgScriptPath/uploads"; ## Wiki 1.5 defaults to /images, but allows more than just images
$wgUploadDirectory = "$IP/uploads"; ## Wiki 1.5 defaults to /images, but allows more than just images
## To enable image uploads, make sure the above '$wgUploadPath' directory is writable by Apache User or group.
## ''(i.e. chmod og+w uploads images)'' then the following should be true:
$wgEnableUploads = true;
$wgUseImageResize = true;
$wgUseImageMagick = true;
$wgImageMagickConvertCommand = "/usr/bin/convert";
## If you want to use image uploads under safe mode, create the directories images/archive, images/thumb and
## images/temp, and make them all writable. Then uncomment this, if it's not already uncommented:
$wgHashedUploadDirectory = false;
</source>
If you want to be able to resize images on the fly to support thumbnails, MediaWiki needs a working [[:w:ImageMagick|ImageMagick]] installation. Set the '''[[Manual:$wgUseImageResize|$wgUseImageResize]]''' and '''[[Manual:$wgUseImageMagick|$wgUseImageMagick]]''' variables to '''true''' once you have installed and tested ImageMagick on your system. Make sure the '''[[Manual:$wgImageMagickConvertCommand|$wgImageMagickConvertCommand]]''' variable points to the proper location of the <tt>convert</tt> command of your installation and that the command is executable by the web server process.
Also, you may want to modify the list of accepted extensions, which is stored within the '''[[Manual:$wgFileExtensions|$wgFileExtensions]]''' array:
<source lang="php">
$wgFileExtensions = array('png','jpg','jpeg','ogg','doc','xls','ppt','mp3','sxc','pdf','nse');
</source>
In case you run into trouble with ImageMagick, and obtain the following error message:
:<tt>Fatal error: mime_magic could not be initialized, magic file is not available in includes/MimeMagic.php on line 506</tt>
Try adding the following line to LocalSettings.php:
[[Manual:$wgMimeDetectorCommand|$wgMimeDetectorCommand]] = "file -bi";
'''See also:''' [[Manual:Configuring file uploads]], [[Manual:Mime type detection]], and [[Manual:Image Administration#Image thumbnailing]] <!-- should be synced or merged! -->
===LaTeX inline equations===
In order to render [[m:Help:Formula|mathematical formulae]] in [[:w:LaTeX|LaTeX]], you need a working LaTeX installation on your system. Set the '''[[Manual:$wgUseTeX|$wgUseTeX]]''' variable to '''true''' to enable that feature. Also make sure the '''[[Manual:$wgMathPath|$wgMathPath]]''', '''[[Manual:$wgMathDirectory|$wgMathDirectory]]''' and '''[[Manual:$wgTmpDirectory|$wgTmpDirectory]]''' are set properly, but you might want to go with the default values unless you have a very good reason to change it.
===Interwiki support===
[[w:InterWiki|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 [[Manual:$wgSitename|$wgSitename]], but in case you need to change that, you set the '''[[Manual:$wgLocalInterwiki|$wgLocalInterwiki]]''' variable to the preferred name.
===Language of user interface===
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 '''[[Manual:$wgLanguageCode|$wgLanguageCode]]''' variable to the proper [[Special:SiteMatrix|language code]] (e.g. "de" for German, "es" for Spanish, etc.)
You may use any of the languages found in the directory language. E.g., if you find MessagesEs.php, you can use "'''<code>es</code>'''" for Spanish. Do not use "<code>Es</code>" 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.
With your command line tool, go to your wiki directory, open the "maintenance" folder, and type "<code>php rebuildMessages.php --rebuild</code>". Please note that on Windows, the PHP folder might not be included in the PATH environment variable.
Not all languages are supported. See [[localisation statistics|here]] for a list of the localisation statistics of {{CURRENTVERSION}}. See [[betawiki:Translating:Statistics|translatewiki.net]] for the statistics per released version.
===Setting copyright for the site===
* '''[[Manual:$wgRightsPage|$wgRightsPage]]''' is the page on the wiki that covers the copyrights that it falls under. Usually, this will be [[Project:Copyrights]].
* '''[[Manual:$wgRightsUrl|$wgRightsUrl]]''' is the page describing full details of your license. (For the GNU FDL, for example, this would be <code>http://www.gnu.org/licenses/fdl.html</code>.)
* '''[[Manual:$wgRightsText|$wgRightsText]]''' is the text in the footer that follows "Content is available under". It will be linked to the page specified in <code>$wgRightsPage</code>.
* '''[[Manual:$wgRightsIcon|$wgRightsIcon]]''' is the URL of the image placed at the left of the footer.
*:Note: If <code>$wgRightsPage</code> is non-empty, the link in the copyright/license notice will link to that page on your site. If <code>$wgRightsPage</code> is empty then the copyright/license notice will link to <code>$wgRightsUrl</code> instead.
* '''[[Manual:$wgEnableDublinCoreRdf|$wgEnableDublinCoreRdf]]''' and '''[[Manual:$wgEnableCreativeCommonsRdf|$wgEnableCreativeCommonsRdf]]''' to add [[:w:Resource Description Framework|RDF]] meta data to wiki pages. For more details about RDF metadata see [[:m:RDF metadata|RDF metadata]].
To modify the copyright statements of the site, add something like this to LocalSettings.php:
<source lang="php">
$wgRightsPage = "YourWiki:Copyright";
$wgRightsText = "copyright YourWiki";
</source>
Afterwards, edit [[MediaWiki:Copyright]] to provide an appropriate message, using <code>"$1"</code> to indicate the position where the link to your copyright page will be.
'''Example: setting a [[w:Creative Commons|Creative Commons]] license'''
To set a Creative Commons license do the following:
* Choose your license: http://creativecommons.org/text/publish-website
* Examine the returned HTML code, e.g.:
<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/2.5/">
<img alt="Creative Commons License" border="0" src="http://creativecommons.org/images/public/somerights20.png" />
</a>
This work is licensed under a
<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/2.5/">
Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License</a>.
* For <code>$wgRightsURL</code> enter the href info from the first anchor:
<source lang="php">$wgRightsUrl = "http://creativecommons.org/licenses/by-nc-sa/2.5/";</source>
* For <code>$wgRightsText</code> enter the text the second anchor links from (add the "a" to the Wiki variable for a more grammatically correct version)
<source lang="php">$wgRightsText = "a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License";</source>
* For <code>$wgRightsIcon</code> 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.
<source lang="php">$wgRightsIcon = "http://creativecommons.org/images/public/somerights20.png";</source>
* For using RDF metadata about copyright add one or both of the following lines to your LocalSettings.php
<source lang="php">
$wgEnableCreativeCommonsRdf = true;
$wgEnableDublinCoreRdf = true;
</source>
===Custom namespaces===
By declaring the '''[[Manual:$wgExtraNamespaces|$wgExtraNamespaces]]''' array, and modifying the '''[[Manual:$wgNamespacesWithSubpages|$wgNamespacesWithSubpages]]''', and '''[[Manual:$wgNamespacesToBeSearchedDefault|$wgNamespacesToBeSearchedDefault]]''' arrays, extra namespaces can be added to a MediaWiki installation; and by declaring the '''[[manual:$wgNamespaceAliases|$wgNamespaceAliases]]''' array namespace aliases can be added. '''Take heed''' not to have any pages already titled in that namespace, for instance in 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 [[Manual:Using custom namespaces|Custom namespaces]] for more information as to how to do so.
===Skins===
The default skin of the site can be modified via the '''[[Manual:$wgDefaultSkin|$wgDefaultSkin]]''' variable.
==See also==
*[[Manual:Wiki family|Wiki families]] can share the same {{PAGENAME}}
*[[Extension:Configure]] provides a way to set configuration settings from a special page
[[Category:MediaWiki configuration/zh-cn| ]]
{{languages|Manual:LocalSettings.php}}All content in the above text box is licensed under the Creative Commons Attribution-ShareAlike license Version 4 and was originally sourced from https://mediawiki.org/w/index.php?oldid=551203.
![]() ![]() This site is not affiliated with or endorsed in any way by the Wikimedia Foundation or any of its affiliates. In fact, we fucking despise them.
|