allwiki首页  
天下维客 你可以修改的网络知识库
首页最近更改优秀条目专题展示电脑科技词典软件学习网络知识电脑安全明星时尚天下百科
 

LocalSettings.php

天下维客,你可以修改的网络知识库

Jump to: navigation, search

目录

Overview

The file LocalSettings.php contains the local configuration of a MediaWiki installation. You should take your time to review the settings in this file. The file is usually generated by the web-based MediaWiki installer but you might want to tweak one or the other parameter (probably in concert with Apache settings).

Changing a setting usually means changing the value of a PHP variable. You might want to make yourself familiar with the PHP syntax first before going ahead. If you are too lazy, keep in mind that PHP variables are accessed by prepending a "$" character before the variable name; many variables are simply set to either
true
or
false
.

The default values of many more settings are set in includes/DefaultSettings.php, which should not be edited; if the variable you want to change is not already mentioned in your LocalSettings.php, copy the appropriate line from DefaultSettings and modify it appropriately. See Configuration settings index and the comments included in the settings files for help on what the variables do.

Standard Settings

Include Path

The IP (include path) variable holds the local file path to the base installation of your wiki. Make sure you refer to the fully qualified file path. Do not include a slash at the end of the path.

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

Site Name

The wgSitename variable holds the name of your wiki setup. This name gets included many times throughout the system. For instance, the Wikipedia tagline "'From Wikipedia, the free encyclopedia."' makes use of this setting.

Script Path

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 settings, especially if you are using Apache's rewrite rules.

Server name

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 wgServer overwrites the detection and the server name will be constant.

Add a line such as

$wgServer = 'http://www.domain.tld'; # add such a line, www.domain.tld being the server address of your wiki as seen from the internet.

{{SERVER}} can be used on wiki pages, it equals the value of $wgServer.

Script Name

wgScript is the name of the main (index) MediaWiki PHP script, named index.php by default. You might want to tweak the path to the script while 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 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

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 wgScript) and use the $1 placeholder for the article name.

if you are using Apache rewrite rules to create pretty and short URLs, you probably need to adjust wgArticlePath 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.

Typical values are

"$wgScript/$1" pass the article name with a / separator
"$wgScript?title=$1" pass the article name as a parameter (old style)
"mypath/$1" custom path. Use Apache rewrite rules to convert "mypath" to the proper path accessing the main script

Stylesheet Location

Use the wgStylePath variable to set the URL path to the place where the stylesheets (CSS) for the MediaWiki installation are located. The wgStyleDirectory 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 wgUploadPath variable specifies the URL path, the wgUploadDirectory points to the local file system path.

Logo

The wgLogo variable specifies the relative URL pointing to the graphical logo that gets displayed on the top left corner by default. You might want to point the variable to the Upload Directory to be able to exchange the logo by updating uploaded files.

Contact Info

The 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 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 MySQL database to store pages, modifications, user information and a lot more things.

The 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.

wgDBname is the database name of the database to be used by MediaWiki. A single MySQL 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 the same database server.

The wgDBuser and 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.

Also keep in mind that the LocalSettings.php permissions should not allow other users to view this file as it contains security-related data.

User rights

The wgGroupPermissions is an associative array, controlling permissions for creating and editing pages for your different user groups. See Help:User rights

Force Capital Links

By default, all article names are forced to start with a capital (roman) letter unless they start with a non-alphabetical character. If you want to allow article names to start with a lowercase character you must adjust the wgCapitalLinks variable. Setting it to false allows lowercase characters, true chooses the default behaviour.

Enabling subpages

Subpages are enabled on a per-namespace basis. For example, to enable subpages in the main namespace:

$wgNamespacesWithSubpages[NS_MAIN] = 1;

$wgUseRCPatrol = true;

Advanced Settings

Direct SQL Queries

To allow SQL queries through the wiki's Special:Asksql page, you can enable direct SQL queries via the web interface. THIS IS VERY INSECURE. If you want to allow semipublic read-only SQL access for your sysops, you should define a MySQL user with limited privileges.

Review the MySQL documentation at http://www.mysql.com/doc/en/GRANT.html on how permissions can be granted in the database subsystem.

The wgAllowSysopQueries must be set to true if you want the direct SQL query feature to be turned on. The wgDBsqluser and the wgDBsqlpassword contain the login name and password to use to access the database with that feature.

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 wgEnableUploads 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.

$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>(i.e.  chmod og+w uploads images)</i>  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;

If you want to be able to resize images on the fly to support thumbnails, MediaWiki needs a working ImageMagick installation. Set the variable $wgUseImageMagick to true once you have installed and tested ImageMagick on your system. Make sure the wgImageMagickConvertCommand variable points to the proper location of the convert 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:

$wgFileExtensions = array('png','jpg','jpeg','ogg','doc','xls','ppt','mp3','sxc','pdf','nse');

LaTeX inline equations

In order to render mathematical formulas in LaTeX, you need a working LaTeX installation on your system. Set the $wgUseTeX to true to enable that feature. Also make sure the wgMathPath, wgMathDirectory and wgTmpDirectory are set properly, but you might want to go with the default values unless you have a very good reason to change it.

See Also

InterWiki support

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 wgSitename but in case you need to change that, you set the wgLocalInterwiki variable to the preferred name.

User Interface Language

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 wgLanguageCode variable to the proper language code (e.g. "de" for german, "es" for spanish, etc.)

File cache

See File cache.

Setting Copyright of the site

This is not documented yet, but a little experimentation demonstrates that the following works.

  • $wgRightsPage
    is the page on the wiki that covers the copyrights that it falls under. Usually, this will be Project:Copyrights.
  • $wgRightsText
    is the text in the footer that follows "Content is available under". It will be linked to the page specified in
    $wgRightsPage
    .
  • $wgRightsIcon
    is the URL of the image placed at the left of the footer.
  • $wgRightsUrl
    is the page describing full details of your license. (For the GNU FDL, for example, this would be
    http://www.gnu.org/licenses/fdl.html
    .)
  • $wgEnableDublinCoreRdf
    and
    $wgEnableCreativeCommonsRdf
    to add rdf meta data to wiki pages

Add something like this to LocalSettings.php

$wgRightsPage = "YourWiki:Copyright"; 
$wgRightsText = "copyright YourWiki";

Edit MediaWiki:Copyright to provide an appropriate message, using "$1" to indicate the position where the link to your copyright page will be.

Still required: explanation of the functions of the remaining variables:

$wgRightsUrl = "";
$wgRightsIcon = "";

To set a Creative Commons license do the following:

<a rel="license" href="<a href="http://creativecommons.org/licenses/by-nc-sa/2.5/" class="external free" target="_blank" title="http://creativecommons.org/licenses/by-nc-sa/2.5/" rel="nofollow">http://creativecommons.org/licenses/by-nc-sa/2.5/</a>">
<img alt="Creative Commons License" border="0" src="<img src="http://creativecommons.org/images/public/somerights20.png" alt="somerights20.png" />" />
</a>
This work is licensed under a
<a rel="license" href="<a href="http://creativecommons.org/licenses/by-nc-sa/2.5/" class="external free" target="_blank" title="http://creativecommons.org/licenses/by-nc-sa/2.5/" rel="nofollow">http://creativecommons.org/licenses/by-nc-sa/2.5/</a>">
Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License</a>.
  • For
    $wgRightsURL
    enter the href info from the first anchor:
$wgRightsUrl = "<a href="http://creativecommons.org/licenses/by-nc-sa/2.5/" class="external free" target="_blank" title="http://creativecommons.org/licenses/by-nc-sa/2.5/" rel="nofollow">http://creativecommons.org/licenses/by-nc-sa/2.5/</a>";
  • For
    $wgRightsText
    enter the text the second anchor links from (add the "a" to the Wiki variable for a more grammatically correct version)
$wgRightsText = "a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License";
  • For
    $wgRightsIcon
    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.
$wgRightsIcon = "<img src="http://creativecommons.org/images/public/somerights20.png" alt="somerights20.png" />";
  • For using rdf meta data about copyright add one or both of the following lines to your LocalSettings.php
$wgEnableCreativeCommonsRdf = true;
$wgEnableDublinCoreRdf = true;

For more details about rdf meta-data see RDF_metadata

Note: If $wgRightsPage is non-empty, the link in the copyright/license notice will link to that page on your site. If $wgRightsPage is empty then the copyright/license notice will link to $wgRightsUrl instead.

Custom Namespaces

See Custom namespaces

Enabling a Debug Log

See WgDebugLogFile

Enabling calculations

include("extensions/calc.php");

开启ajax功能

Image:使用ajax搜索功能.png
开启ajax之后,使用即时搜索功能

目前可以确认,至少在版本1.7之后便引入了ajax支持,此功能默认关闭,添加以下行进行开启:

$wgUseAjax = true

$wgLocaltimezone = "Asia/Shanghai"; putenv("TZ=$wgLocaltimezone"); $wgLocalTZoffset = date("Z") / 60;


Personal tools
工具
金银币拍卖 金币拍卖预展  金银币网店 熊猫金银币 生肖金银币