Jump to content

매뉴얼:LocalSettings.php

From mediawiki.org
This page is a translated version of the page Manual:LocalSettings.php and the translation is 18% complete.
Outdated translations are marked like this.
경고 경고: Don't edit LocalSettings.php with document editors like Notepad on Windows 10 Version 1809 or earlier, TextEdit, or other text editors that add byte order marks to files. These break the PHP runtime of your wiki. Instead, use a code editor, e.g. Vim or Notepad++. These handle file encodings properly. They can also be used to repair files previously broken by document editors.

The LocalSettings.php file provides basic configuration settings 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 can tweak the parameters, possibly in concert with Apache settings. For MediaWiki installations configured as a wiki farm, a file named CommonSettings.php may be used.

서버에서의 위치

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 MediaWiki-Vagrant#MediaWiki_settings.)

보안

LocalSettings.php 보통 데이터베이스 로그인에 필요한 민감한 데이터를 포함합니다. 이 데이터는 "절대" 제 3자한테 드러다면 안됩니다! 서버에서 어딘가의 보안 위반으로 인하여, 아마 다른 사용자가 서버의 파일에 접근 가능한 일이 일어날 수도 있습니다. 데이터의 보안을 향상시키려면, 이 파일의 유닉스 퍼미션 설정을 적절히 하여야 하며, 웹서버 유저는 이 파일에 반드시 접근할 수 있어야 합니다. 파일의 소유자의 계정이 같다면, 퍼미션을 '600'으로 설정할 수 있습니다. 간혹, 웹서버 유저가 파일의 소유자가 아닐 경우, 그들의 유닉스 유저 그룹을 조절하세요. 이 경우, '640' 퍼미션은 좋습니다. 보안을 향상하기 위해서는 가능한 최소한의 퍼미션으로 줄이십시오.

추가적으로, 위키의 데이터베이스와 LocalSettings.php에서 사용자의 자격 제공으로 제한이 되는 새로운 MySQL 사용자를 만들 수도 있습니다. 또한 localhost 에서만 데이터베이스 서버에 접근할 수 있도록 설정할 수 있으며, 자격 증명이 외부에 노출된 경우를 예방할 수 있습니다.

See also Manual:Securing database passwords for a method to move the sensitive parts of LocalSettings.php to a different file in a different directory.

파일 내용물

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, although in some cases you may need to clear your browser's cache to actually see the changes you made.

The default values of configuration settings are set in includes/MainConfigSchema.php, which should not be edited; if the variable you want to change is not already mentioned in your LocalSettings.php, add a line to that file modify it appropriately. 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/ExtensionName.php"; or wfLoadExtension( 'ExtensionName' ), which point to extensions. These lines enable the corresponding extension in the wiki. Those extensions may require setting the values of more variables in LocalSettings.php; check the documentation of the extension itself for further instructions.

Like most PHP files in MediaWiki, LocalSettings.php does not end with the closing PHP tag ?>. 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. [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.

This file is not written to your webserver automatically for security reasons. Instead, it is offered as a download, which you must then upload to your server for your wiki to begin working. For a more complete explanation, see this explanation.


가능한 설정 미리보기

See the 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.

기본 설정

Install path

The $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. Setting $IP manually in LocalSettings.php is no longer needed. $IP will default to the current working directory and can be used without the need to manually define it. Attempting to set $IP (or MW_INSTALL_PATH) in LocalSettings.php may produce unexpected results.

사이트 이름

$wgSitename 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 $wgGrammarForms (for example please refer to the $wgSitename documentation page).

스크립트 경로

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

서버 이름

$wgServer 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 $wgServer must be set in LocalSettings.php. Prior to that, MediaWiki tried to autodetect the name of the server and $wgServer 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 {{SERVER}} can be used on wiki pages; it equals the value of $wgServer; 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 //www.mediawiki.org, 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 $wgCanonicalServer. $wgCanonicalServer 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

$wgScript 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

$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. See 매뉴얼:Short URL 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

스타일시트 위치

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

업로드 경로

The upload directory is the place where files uploaded by the users are stored. $wgUploadPath specifies the URL path, $wgUploadDirectory points to the local file system path.

로고

$wgLogo specifies which graphical logo is displayed in the top left corner of all MediaWiki pages.

See 매뉴얼:FAQ for how to change the logo.

Contact info

$wgEmergencyContact 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.

$wgPasswordSender 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.

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

$wgDBuser and $wgDBpassword 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 Manual:Securing database passwords for a method to move the sensitive parts of LocalSettings.php to a different file in a different directory.

사용자 권한

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

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 $wgCapitalLinks . Setting it to false allows lowercase characters, true chooses the default behavior.

Enabling subpages

In LocalSettings.php, subpages are enabled on a per-namespace basis using $wgNamespacesWithSubpages . For example, to enable subpages in the main namespace:

$wgNamespacesWithSubpages[NS_MAIN] = 1;

이미지 업로드

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 $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.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 $wgUseImageMagick to true once you have installed and tested ImageMagick on your system. Make sure $wgImageMagickConvertCommand points to the proper location of the convert command of your installation, that the command is executable by the web server process, and $wgMaxShellMemory is large enough. See Manual:Image administration#Image thumbnailing for detailed information and troubleshooting.

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

$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:

$wgMimeDetectorCommand = "file -bi";

인터위키 지원

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 $wgLocalInterwikis 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 $wgLanguageCode 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 languages/i18n. 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.

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 maintenance folder, and enter php rebuildMessages.php --rebuild. On Windows, the PHP folder might not be in your PATH environment variable and you'll have to prefix php with the path to the program.

Not all languages are supported. See the 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.

  • $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.
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.

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-footer to provide an appropriate message, using "$1" to indicate the position where the link to your copyright page will be.

예제: Creative Commons License 설정'

To set a Creative Commons license do the following:

  • Examine the returned HTML code, e.g.:
<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";

커스텀 이름공간

By declaring $wgExtraNamespaces , and modifying $wgNamespacesWithSubpages , and $wgNamespacesToBeSearchedDefault , 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.

스킨

The default skin of the site can be modified via $wgDefaultSkin .

같이 보기