MediaWiki/LocalSettings.php: Unterschied zwischen den Versionen

Aus Foxwiki
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Zeile 2: Zeile 2:


= TMP =
= TMP =
The '''<code>LocalSettings.php</code>''' file provides basic [[<tvar name=2>Special:MyLanguage/Manual:Configuration settings|configuration settings]] of a [[<tvar name=4>Special:MyLanguage/MediaWiki|MediaWiki]] installation.
The '''<code>LocalSettings.php</code>''' file provides basic [[<tvar name=2>Special:MyLanguage/Manual:Configuration settings|configuration settings]] of a [[<tvar name=4>Special:MyLanguage/MediaWiki|MediaWiki]] installation.
You should take your time to review the settings in this file.
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 can tweak the parameters, possibly in concert with Apache settings.
The file is usually generated by the web-based MediaWiki installer but you can tweak the parameters, possibly in concert with Apache settings.
For MediaWiki installations configured as a [[<tvar name=2>Special:MyLanguage/Manual:Wiki family|wiki farm]], a file named <code>{{ll|Manual:CommonSettings.php|CommonSettings.php}}</code> may be used.
For MediaWiki installations configured as a [[<tvar name=2>Special:MyLanguage/Manual:Wiki family|wiki farm]], a file named <code>{{ll|Manual:CommonSettings.php|CommonSettings.php}}</code> may be used.




== Location on the server ==  
== Location on the server ==  


The <code>LocalSettings.php</code> file is not a wiki page, and you cannot access it with your web browser.
The <code>LocalSettings.php</code> file is not a wiki page, and you cannot access it with your web browser.


Instead, it is a file in the file system of the server.
Instead, it is a file in the file system of the server.
Its contents are generated during the initial setup of the wiki, and the resulting file must be copied to the server manually.
Its contents are generated during the initial setup of the wiki, and the resulting file must be copied to the server manually.
The file must be located in the folder you installed MediaWiki into, on the same level with folders like <code>includes/</code> and <code>skins/</code> and files like <code>api.php</code>.
The file must be located in the folder you installed MediaWiki into, on the same level with folders like <code>includes/</code> and <code>skins/</code> and files like <code>api.php</code>.
If this file is ''not'' there, the wiki will not work at all—if the wiki ''does'' work, the file ''is there''.
If this file is ''not'' there, the wiki will not work at all—if the wiki ''does'' work, the file ''is there''.
If you do not know where it is, you can enter a command such as <kbd>find / -iname LocalSettings.php -print</kbd> in a terminal window to locate it.
If you do not know where it is, you can enter a command such as <kbd>find / -iname LocalSettings.php -print</kbd> in a terminal window to locate it.




Zeile 24: Zeile 24:
== Security ==  
== Security ==  


<code>LocalSettings.php</code> usually contains sensitive data such as database logins.
<code>LocalSettings.php</code> usually contains sensitive data such as database logins.
This data should ''never'' be revealed to the public!
This data should ''never'' be revealed to the public!
Due to a security breach somewhere on the server, it might happen that other users are able to view the contents of files.
Due to a security breach somewhere on the server, it might happen that other users are able to view the contents of files.
In order to improve security of your data, you should set UNIX permissions for this file accordingly: The webserver user must have access to this file.
In order to improve security of your data, you should set UNIX permissions for this file accordingly: The webserver user must have access to this file.
If this is the same account, who is the owner of the file, then you can set permissions to ''600''.
If this is the same account, who is the owner of the file, then you can set permissions to ''600''.
Sometimes, the webserver user is ''not'' the file owner, but they are in the owner's UNIX user group.
Sometimes, the webserver user is ''not'' the file owner, but they are in the owner's UNIX user group.
In this case, permissions of ''640'' should be fine. For improved security you should narrow permissions down as far as possible.
In this case, permissions of ''640'' should be fine. For improved security you should narrow permissions down as far as possible.




Zeile 48: Zeile 48:




The ''default'' values of many more settings are set in <code>includes/DefaultSettings.php</code>, ''which should not be edited;'' if the variable you want to change is not already mentioned in your <tvar name=2><code>LocalSettings.php</code>, copy the appropriate line from <code>DefaultSettings.php</code> and modify it appropriately in <tvar name=2><code>LocalSettings.php</code>.
The ''default'' values of many more settings are set in <code>includes/DefaultSettings.php</code>, ''which should not be edited;'' if the variable you want to change is not already mentioned in your <tvar name=2><code>LocalSettings.php</code>, copy the appropriate line from <code>DefaultSettings.php</code> and modify it appropriately in <tvar name=2><code>LocalSettings.php</code>.
''' Within <code>LocalSettings.php</code> you can add new lines at the end.'''
''' Within <code>LocalSettings.php</code> you can add new lines at the end.'''


Within the file, there can also be several lines such as '<code>require_once "$IP/extensions/''extension''.php";</code>', which point to [[<tvar name=ext-content>Special:MyLanguage/Extension:Contents|extensions]].
Within the file, there can also be several lines such as '<code>require_once "$IP/extensions/''extension''.php";</code>', which point to [[<tvar name=ext-content>Special:MyLanguage/Extension:Contents|extensions]].
These lines enable the according extension in the wiki.
These lines enable the according extension in the wiki.
Those extensions may require setting the values of more variables in <code>LocalSettings.php</code>; check the documentation of the according extension for further instructions.
Those extensions may require setting the values of more variables in <code>LocalSettings.php</code>; check the documentation of the according extension for further instructions.




Zeile 75: Zeile 75:
===Install path===  
===Install path===  


The '''{{ll|Manual:$IP|$IP}}''' (install path) variable holds the local file path to the base installation of your wiki.
The '''{{ll|Manual:$IP|$IP}}''' (install path) variable holds the local file path to the base installation of your wiki.
Since MediaWiki 1.18, the system sets $IP automatically.
Since MediaWiki 1.18, the system sets $IP automatically.
Setting {{phpi|$IP}} manually in <tvar name=2><code>LocalSettings.php</code> is no longer needed.
Setting {{phpi|$IP}} manually in <tvar name=2><code>LocalSettings.php</code> is no longer needed.
{{phpi|$IP}} will default to the current working directory and can be used without the need to manually define it.
{{phpi|$IP}} will default to the current working directory and can be used without the need to manually define it.
Attempting to set {{phpi|$IP}} (or <code>MW_INSTALL_PATH</code>) in <code>LocalSettings.php</code> may produce unexpected results.
Attempting to set {{phpi|$IP}} (or <code>MW_INSTALL_PATH</code>) in <code>LocalSettings.php</code> may produce unexpected results.




Zeile 92: Zeile 92:
=== Declensions of site name ===  
=== Declensions of site name ===  


Some translations of interface are ready for inflection of site name.
Some translations of interface are ready for inflection of site name.
You can set proper forms of word in variables '''{{ll|Manual:$wgGrammarForms|$wgGrammarForms}}''' (for example please refer to the <tvar name=2>'''{{ll|Manual:$wgSitename|$wgSitename}}''' documentation page).
You can set proper forms of word in variables '''{{ll|Manual:$wgGrammarForms|$wgGrammarForms}}''' (for example please refer to the <tvar name=2>'''{{ll|Manual:$wgSitename|$wgSitename}}''' documentation page).




===Site language===  
===Site language===  


'''{{ll|Manual:$wgLanguageCode|$wgLanguageCode}}''' controls the language of your wiki's interface.
'''{{ll|Manual:$wgLanguageCode|$wgLanguageCode}}''' controls the language of your wiki's interface.
While users can switch the language they see in their [[Special:Preferences|preferences]], this variable sets the default language that all anonymous users and most registered users see.  
While users can switch the language they see in their [[Special:Preferences|preferences]], this variable sets the default language that all anonymous users and most registered users see.  




===Script path===  
===Script path===  


'''{{ll|Manual:$wgScriptPath|$wgScriptPath}}''' is the URL path prefix to access the main MediaWiki script that is the central acting piece of code of MediaWiki.
'''{{ll|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 [[Special:MyLanguage/Apache configuration|Apache settings]], especially if you are using Apache's [[w:Rewrite_engine|rewrite]] rules.
This setting should correspond to the [[Special:MyLanguage/Apache configuration|Apache settings]], especially if you are using Apache's [[w:Rewrite_engine|rewrite]] rules.




Zeile 114: Zeile 114:




From MediaWiki 1.34 {{phpi|$wgServer}} must be set in <tvar name=2>LocalSettings.php.
From MediaWiki 1.34 {{phpi|$wgServer}} must be set in <tvar name=2>LocalSettings.php.
Prior to that, MediaWiki tried to autodetect the name of the server and {{phpi|$wgServer}} was optional, to override the autodetection.
Prior to that, MediaWiki tried to autodetect the name of the server and {{phpi|$wgServer}} was optional, to override the autodetection.




Zeile 131: Zeile 131:




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


<syntaxhighlight lang="php">
<syntaxhighlight lang="php">
Zeile 148: Zeile 148:
===Article path===  
===Article path===  


<tvar name=ArticlePath>'''{{ll|Manual:$wgArticlePath|$wgArticlePath}}''' is the path to use when accessing a page in MediaWiki.
<tvar name=ArticlePath>'''{{ll|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 {{phpi|$wgScript}}) and use the <tvar name=2><code>$1</code> placeholder for the article name.
The path should contain the path to the main script (usually making use of {{phpi|$wgScript}}) and use the <tvar name=2><code>$1</code> placeholder for the article name.


If you are using Apache rewrite rules to create pretty and short URLs, you probably need to adjust {{phpi|$wgArticlePath}} to address the right path.
If you are using Apache rewrite rules to create pretty and short URLs, you probably need to adjust {{phpi|$wgArticlePath}} to address the right path.
Note that wgArticlePath is used to construct URLs from within MediaWiki.
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.
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 {{ll|Manual:Short URL}} for more information on URL configuration.
See {{ll|Manual:Short URL}} for more information on URL configuration.




Zeile 175: Zeile 175:
===Stylesheet location===  
===Stylesheet location===  


Use '''{{ll|Manual:$wgStylePath|$wgStylePath}}''' to set the URL path to the place where the stylesheets (CSS) for the MediaWiki installation are located.
Use '''{{ll|Manual:$wgStylePath|$wgStylePath}}''' to set the URL path to the place where the stylesheets (CSS) for the MediaWiki installation are located.
'''{{ll|Manual:$wgStyleDirectory|$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.
'''{{ll|Manual:$wgStyleDirectory|$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.




Zeile 211: Zeile 211:




MediaWiki 1.35 introduced {{ll|Manual:$wgLogos|$wgLogos}}, which allows multiple versions of the same logo.
MediaWiki 1.35 introduced {{ll|Manual:$wgLogos|$wgLogos}}, which allows multiple versions of the same logo.
An example of using multiple logos is shown below.
An example of using multiple logos is shown below.


<syntaxhighlight lang="php" style="overflow:auto;">
<syntaxhighlight lang="php" style="overflow:auto;">
$wgLogos = [
$wgLogos = [
'1x' => "$wgStylePath/common/images/1x_version.png",
'1x' => "$wgStylePath/common/images/1x_version.png",
'1.5x' => "$wgStylePath/common/1.5x_version.png",
'1.5x' => "$wgStylePath/common/1.5x_version.png",
...
...
'tagline' => [
'tagline' => [
'src' => "$wgStylePath/common/tagline_version.png",
'src' => "$wgStylePath/common/tagline_version.png",
'width' => 135,
'width' => 135,
'height' => 15,
'height' => 15,
],
],
];
];
</syntaxhighlight>
</syntaxhighlight>
Zeile 251: Zeile 251:




Also see {{ll|Manual:Securing database passwords}} for a method to move the sensitive parts of <code>LocalSettings.php</code> to a different file in a different directory.
Also see {{ll|Manual:Securing database passwords}} for a method to move the sensitive parts of <code>LocalSettings.php</code> to a different file in a different directory.




Zeile 303: Zeile 303:
</syntaxhighlight>
</syntaxhighlight>


If you want to be able to resize images on the fly to support thumbnails, MediaWiki needs a working [[w:ImageMagick|ImageMagick]] installation.
If you want to be able to resize images on the fly to support thumbnails, MediaWiki needs a working [[w:ImageMagick|ImageMagick]] installation.
Set '''{{ll|Manual:$wgUseImageMagick|$wgUseImageMagick}}''' to '''true''' once you have installed and tested ImageMagick on your system.
Set '''{{ll|Manual:$wgUseImageMagick|$wgUseImageMagick}}''' to '''true''' once you have installed and tested ImageMagick on your system.
Make sure '''{{ll|Manual:$wgImageMagickConvertCommand|$wgImageMagickConvertCommand}}''' points to the proper location of the <tvar name=2><code>convert</code> command of your installation, that the command is executable by the web server process, and <tvar name=3>'''{{ll|Manual:$wgMaxShellMemory|$wgMaxShellMemory}}''' is large enough.
Make sure '''{{ll|Manual:$wgImageMagickConvertCommand|$wgImageMagickConvertCommand}}''' points to the proper location of the <tvar name=2><code>convert</code> command of your installation, that the command is executable by the web server process, and <tvar name=3>'''{{ll|Manual:$wgMaxShellMemory|$wgMaxShellMemory}}''' is large enough.
See {{ll|Manual:Image administration#Image thumbnailing|Manual:Image administration#Image thumbnailing}} for detailed information and troubleshooting.
See {{ll|Manual:Image administration#Image thumbnailing|Manual:Image administration#Image thumbnailing}} for detailed information and troubleshooting.




Zeile 323: Zeile 323:


<blockquote>
<blockquote>
Fatal error: mime_magic could not be initialized, magic file is not available in includes/MimeMagic.php on line 506
Fatal error: mime_magic could not be initialized, magic file is not available in includes/MimeMagic.php on line 506
</blockquote>
</blockquote>


Zeile 349: Zeile 349:
===Interwiki support===  
===Interwiki support===  


InterWiki support is built into MediaWiki but you need to configure the prefix to be used for your internal links.
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 {{wg|Sitename}}, but in case you need to change that, you set the <tvar name=2>{{wg|LocalInterwikis}} variable to the preferred name.
This prefix is usually the same as {{wg|Sitename}}, but in case you need to change that, you set the <tvar name=2>{{wg|LocalInterwikis}} variable to the preferred name.




Zeile 365: Zeile 365:
{{note|1= 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 <code>maintenance</code> folder, and enter <syntaxhighlight lang=bash inline>php rebuildMessages.php --rebuild</syntaxhighlight>.  On Windows, the PHP folder might not be in your <code>PATH</code> environment variable and you'll have to prefix <kbd>php</kbd> with the path to the program.}}
{{note|1= 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 <code>maintenance</code> folder, and enter <syntaxhighlight lang=bash inline>php rebuildMessages.php --rebuild</syntaxhighlight>.  On Windows, the PHP folder might not be in your <code>PATH</code> environment variable and you'll have to prefix <kbd>php</kbd> with the path to the program.}}


Not all languages are supported.
Not all languages are supported.
See the [<tvar name=url>https://translatewiki.net/w/i.php?title=Special:MessageGroupStats&group=mediawiki translation statistics on TranslateWiki] for an up-to-date list of which languages are supported and to what extent.
See the [<tvar name=url>https://translatewiki.net/w/i.php?title=Special:MessageGroupStats&group=mediawiki translation statistics on TranslateWiki] for an up-to-date list of which languages are supported and to what extent.
That list reflects the current state of MediaWiki core, so depending on what version you are using there may be a discrepancy.
That list reflects the current state of MediaWiki core, so depending on what version you are using there may be a discrepancy.




Zeile 449: Zeile 449:
===Custom namespaces===  
===Custom namespaces===  


By declaring '''{{ll|Manual:$wgExtraNamespaces|$wgExtraNamespaces}}''', and modifying <tvar name=2>'''{{ll|Manual:$wgNamespacesWithSubpages|$wgNamespacesWithSubpages}}''', and <tvar name=3>'''{{ll|Manual:$wgNamespacesToBeSearchedDefault|$wgNamespacesToBeSearchedDefault}}''', extra namespaces can be added to a MediaWiki installation; and by declaring the <tvar name=4>'''{{ll|Manual:$wgNamespaceAliases|$wgNamespaceAliases}}''' array namespace aliases can be added.
By declaring '''{{ll|Manual:$wgExtraNamespaces|$wgExtraNamespaces}}''', and modifying <tvar name=2>'''{{ll|Manual:$wgNamespacesWithSubpages|$wgNamespacesWithSubpages}}''', and <tvar name=3>'''{{ll|Manual:$wgNamespacesToBeSearchedDefault|$wgNamespacesToBeSearchedDefault}}''', extra namespaces can be added to a MediaWiki installation; and by declaring the <tvar name=4>'''{{ll|Manual:$wgNamespaceAliases|$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.
'''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".
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 {{ll|Manual:Using custom namespaces|Custom namespaces}} for more information as to how to do so.
See {{ll|Manual:Using custom namespaces|Custom namespaces}} for more information as to how to do so.


The default skin of the site can be modified via <tvar name=DefaultSkin>'''{{ll|Manual:$wgDefaultSkin|$wgDefaultSkin}}'''.
The default skin of the site can be modified via <tvar name=DefaultSkin>'''{{ll|Manual:$wgDefaultSkin|$wgDefaultSkin}}'''.

Version vom 4. Juni 2024, 07:45 Uhr

LocalSettings.php ist die Konfigurationsdatei für MediaWiki

TMP

The LocalSettings.php file provides basic [[<tvar name=2>Special:MyLanguage/Manual:Configuration settings|configuration settings]] of a [[<tvar name=4>Special:MyLanguage/MediaWiki|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 can tweak the parameters, possibly in concert with Apache settings. For MediaWiki installations configured as a [[<tvar name=2>Special:MyLanguage/Manual:Wiki family|wiki farm]], a file named Vorlage:Ll may be used.


Location on the server

The LocalSettings.php file is not a wiki page, and you cannot access it with your web browser.

Instead, it is a file in the file system of the server. Its contents are generated during the initial setup of the wiki, and the resulting file must be copied to the server manually. The file must be located in the folder you installed MediaWiki into, on the same level with folders like includes/ and skins/ and files like api.php. If this file is not there, the wiki will not work at all—if the wiki does work, the file is there. If you do not know where it is, you can enter a command such as find / -iname LocalSettings.php -print in a terminal window to locate it.


(If you are using Vagrant, see also [[<tvar name=vagrant>Special:MyLanguage/MediaWiki-Vagrant#mw-settings|MediaWiki-Vagrant#MediaWiki_settings]].)

Security

LocalSettings.php usually contains sensitive data such as database logins. This data should never be revealed to the public! Due to a security breach somewhere on the server, it might happen that other users are able to view the contents of files. In order to improve security of your data, you should set UNIX permissions for this file accordingly: The webserver user must have access to this file. If this is the same account, who is the owner of the file, then you can set permissions to 600. Sometimes, the webserver user is not the file owner, but they are in the owner's UNIX user group. In this case, permissions of 640 should be fine. For improved security you should narrow permissions down as far as possible.


Additionally, you can create a MySQL user, who is restricted to only the database used by the wiki and provide this user's credentials in LocalSettings.php. Also you can configure your database server to only accept connections from localhost - this should prevent access from outside in case of leaked credentials.


See also Vorlage:Ll for a method to move the sensitive parts of <tvar name=2>LocalSettings.php to a different file in a different directory.

File contents

When you edit LocalSettings.php, make sure to save it in the right encoding again. You should use "ANSI as UTF-8" encoding - that is UTF-8 encoding without byte order mark (BOM).


LocalSettings.php contains PHP code; mainly the definition of variables and their values. Changing a setting usually means changing the value of a PHP variable. Your changes will take effect immediately after saving the file again on the server: There is no need to manually "restart" anything. Anyway, in some cases you may need to clear your browser's cache to actually see the changes you made.


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 <tvar name=2>LocalSettings.php, copy the appropriate line from DefaultSettings.php and modify it appropriately in <tvar name=2>LocalSettings.php. Within LocalSettings.php you can add new lines at the end.

Within the file, there can also be several lines such as 'require_once "$IP/extensions/extension.php";', which point to [[<tvar name=ext-content>Special:MyLanguage/Extension:Contents|extensions]]. These lines enable the according extension in the wiki. Those extensions may require setting the values of more variables in LocalSettings.php; check the documentation of the according extension for further instructions.


Like most PHP files in MediaWiki, LocalSettings.php does not end with the closing PHP tag <tvar name=code>Vorlage:Phpi. This prevents admins from accidentally adding new information after this tag. PHP works fine without a closing tag.


If you have a wiki on a MediaWiki wiki farm you may not have write-access (perhaps not even read-access) to the file LocalSettings.php (see e.g. <tvar name=wikiaforum>[1]). 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.


Vorlage:Note


Overview of available settings

See the [[<tvar name=config>Special:MyLanguage/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.

Standard settings

Install path

The Vorlage:Ll (install path) variable holds the local file path to the base installation of your wiki. Since MediaWiki 1.18, the system sets $IP automatically. Setting Vorlage:Phpi manually in <tvar name=2>LocalSettings.php is no longer needed. Vorlage:Phpi will default to the current working directory and can be used without the need to manually define it. Attempting to set Vorlage:Phpi (or MW_INSTALL_PATH) in LocalSettings.php may produce unexpected results.


The Vorlage:Ll file gets loaded from the directory designated by the IP variable.

Site name

Vorlage:Ll holds the name of your wiki setup. This name gets included many times throughout the system, such as via MediaWiki:Pagetitle. For instance, the Wikipedia tagline "From Wikipedia, the free encyclopedia" makes use of this setting.

Declensions of site name

Some translations of interface are ready for inflection of site name. You can set proper forms of word in variables Vorlage:Ll (for example please refer to the <tvar name=2>Vorlage:Ll documentation page).


Site language

Vorlage:Ll 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.


Script path

Vorlage:Ll 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

<tvar name=Server>Vorlage:Ll contains the base URL of the server, including protocol but without the trailing slash and without the subdirectory if any. When the wiki is accessed from either the localhost where it runs, from an intranet or from the internet, email notifications and a few other computed messages would be usually delivered with the different URLs.


From MediaWiki 1.34 Vorlage:Phpi must be set in <tvar name=2>LocalSettings.php. Prior to that, MediaWiki tried to autodetect the name of the server and Vorlage:Phpi was optional, to override the autodetection.


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


$wgServer = 'http://www.example.com';


The magic word variable <tvar name=2>{{SERVER}} can be used on wiki pages; it equals the value of <tvar name=3>Vorlage:Phpi; 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 <tvar name=4>https://wiki.foxtom.de, which can neither be clicked nor copy-pasted into the address bar as it is.


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

$wgServer = '//www.example.com';
$wgCanonicalServer = 'https://www.example.com';


Script name

<tvar name=Script>Vorlage:Ll is the name of the main (index) MediaWiki PHP script, named index.php 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.

Article path

<tvar name=ArticlePath>Vorlage:Ll 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 Vorlage:Phpi) and use the <tvar name=2>$1 placeholder for the article name.

If you are using Apache rewrite rules to create pretty and short URLs, you probably need to adjust Vorlage:Phpi 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 Vorlage:Ll for more information on URL configuration.


Typical values are:


"$wgScript/$1" pass the article name with 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 Vorlage:Ll to set the URL path to the place where the stylesheets (CSS) for the MediaWiki installation are located. Vorlage:Ll 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. Vorlage:Ll specifies the URL path, <tvar name=2>Vorlage:Ll points to the local file system path.

<tvar name=Logo>Vorlage:Ll 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 LocalSettings.php:


$wgLogo = "$wgStylePath/common/images/wiki.png";


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 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 Vorlage:Ll, which allows multiple versions of the same logo. An example of using multiple logos is shown below.

$wgLogos = [
'1x' => "$wgStylePath/common/images/1x_version.png",
'1.5x' => "$wgStylePath/common/1.5x_version.png",
...
'tagline' => [
'src' => "$wgStylePath/common/tagline_version.png",
'width' => 135,
'height' => 15,
],
];


Contact info

<tvar name=EmergencyContact>Vorlage:Ll 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.


<tvar name=PasswordSender>Vorlage:Ll 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.

Database settings

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


<tvar name=DBserver>Vorlage:Ll 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.


<tvar name=DBname>Vorlage:Ll 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.


<tvar name=DBuser>Vorlage:Ll and <tvar name=DBpassword>Vorlage:Ll 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 Vorlage:Ll for a method to move the sensitive parts of LocalSettings.php to a different file in a different directory.


User rights

<tvar name=GroupPermissions>Vorlage:Ll 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 Vorlage:Ll 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 <tvar name=CapitalLinks>Vorlage:Ll. Setting it to false allows lowercase characters, true chooses the default behavior.

Enabling subpages

In LocalSettings.php, [[<tvar name=subpg>Special:MyLanguage/Help:Subpages|subpages]] are enabled on a per-namespace basis using <tvar name=NamespacesWithSubpages>Vorlage:Ll. For example, to enable subpages in the main namespace:


$wgNamespacesWithSubpages[NS_MAIN] = 1;


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 <tvar name=EnableUploads>Vorlage:Ll 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.e.  chmod og+w uploads images)''  then the following should be true:
$wgEnableUploads       = 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 Vorlage:Ll to true once you have installed and tested ImageMagick on your system. Make sure Vorlage:Ll points to the proper location of the <tvar name=2>convert command of your installation, that the command is executable by the web server process, and <tvar name=3>Vorlage:Ll is large enough. See Vorlage:Ll for detailed information and troubleshooting.


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


$wgFileExtensions = [ 'png', 'jpg', 'jpeg', 'ogg', 'doc', 'xls', 'ppt', 'mp3', 'sxc', 'pdf' ];


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 LocalSettings.php:


Vorlage:Ll = "file -bi";

Vorlage:Note


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 Vorlage:Wg, but in case you need to change that, you set the <tvar name=2>Vorlage:Wg 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 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 Vorlage:Git file. E.g. if you find es.json, then you can use "es" for Spanish. Do not use "Es" with a capital letter. Although it seems to work, not all texts are translated.


Vorlage:Note

Not all languages are supported. See the [<tvar name=url>https://translatewiki.net/w/i.php?title=Special:MessageGroupStats&group=mediawiki translation statistics on TranslateWiki] for an up-to-date list of which languages are supported and to what extent. That list reflects the current state of MediaWiki core, so depending on what version you are using there may be a discrepancy.


Setting copyright for the site

  • <tvar name=RightsPage>Vorlage:Ll is the page on the wiki that covers the copyrights that it falls under. Usually, this will be Vorlage:Ll.



  • <tvar name=RightsText>Vorlage:Ll is the text in the footer that follows "Content is available under". It will be linked to the page specified in $wgRightsPage.


  • <tvar name=RightsIcon>Vorlage:Ll is the URL of the image placed at the left of the footer.


Vorlage:Note


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


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


Afterwards, edit MediaWiki:Copyright to provide an appropriate message, using "$1" 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:


<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">
<img alt="Creative Commons License" border="0" src="http://creativecommons.org/images/public/somerights30.png" />
</a>
This work is licensed under a
<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/">
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License</a>.


  • For $wgRightsURL enter the href info from the first anchor:
$wgRightsUrl = "http://creativecommons.org/licenses/by-nc-sa/3.0/";


  • 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 3.0 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 = "http://creativecommons.org/images/public/somerights30.png";


  • For using RDF metadata about copyright add one or both of the following lines to your LocalSettings.php:


$wgEnableCreativeCommonsRdf = true;
$wgEnableDublinCoreRdf = true;


Custom namespaces

By declaring Vorlage:Ll, and modifying <tvar name=2>Vorlage:Ll, and <tvar name=3>Vorlage:Ll, extra namespaces can be added to a MediaWiki installation; and by declaring the <tvar name=4>Vorlage:Ll 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 Vorlage:Ll for more information as to how to do so.

The default skin of the site can be modified via <tvar name=DefaultSkin>Vorlage:Ll.

See also

  • Vorlage:File doclink source code, which generates the inital contents of LocalSettings.php during installation.


  • [[<tvar name=wfamily>Special:MyLanguage/Manual:Wiki family|Wiki families]] can share the same MediaWiki/LocalSettings.php.
  • Vorlage:Ll - a guide to securing your database passwords and LocalSettings.php file.

[[Category:MediaWiki configuration{{#translation:}}| ]]


TMP

$wgReadOnly
  • setzt das Wiki auf schreibgeschützt
  • angegebenen Zeichenfolge als Grund
  • nützlich für die Wartung der Website
/mw-config/


Links

  1. https://www.mediawiki.org/wiki/Manual:Configuration_settings/de
  2. https://www.mediawiki.org/wiki/Manual:LocalSettings.php