“安装MW:初始化配置”的版本间差异
		
		
		
		
		
		跳到导航
		跳到搜索
		
				
		
		
	
|  (→更新) | |||
| (未显示同一用户的20个中间版本) | |||
| 第1行: | 第1行: | ||
| [[category:MediaWiki]] | [[category:MediaWiki]] | ||
| == 配置文件 == | |||
|  MediaWiki 的配置文件有两处: | |||
|  1、<span style="color: blue; font-size: 150%">'''DefaultSettings.php'''</span>:系统默认的配置文件,位于“<span style="color: green">'''./includes/DefaultSettings.php'''</span>”; | |||
|  2、<span style="color: blue; font-size: 150%">'''LocalSettings.php'''</span>:用户设置的配置文件,位于“<span style="color: green">'''./LocalSettings.php'''</span>”; | |||
| 以下主要在 '''LocalSettings.php''' 中进行增加、覆盖、设置相应配置。 | |||
| ==  | === '''配置:短链接'''<ref>[[配置MW:短链接]]</ref> === | ||
| ===  | === 修改:Logo、Favicon === | ||
|  可以使用“<span style="color: green; font-size: 120%">'''Axialis IconWorkshop'''</span>”制作图标(Favicon)。 | |||
| LocalSettings.php 设置: | |||
| : <syntaxhighlight lang="PHP" highlight=""> | |||
| ## The URL path to the logo.  Make sure you change this from the default, | |||
| ## or else you'll overwrite your logo when you upgrade! | |||
| # | # $wgLogo = "$wgResourceBasePath/resources/assets/wiki.png"; | ||
| # | # $wgLogos = [ '1x' => "$wgResourceBasePath/resources/assets/wiki.png" ]; | ||
| #  | $wgLogo = "$wgResourceBasePath/resources/assets/wikioe.png"; | ||
| # | $wgFavicon = "$wgResourceBasePath/resources/assets/wikioe.ico"; | ||
| </syntaxhighlight> | |||
| # | |||
| ==  | === 修改:移除底部的“Powered by”图标 === | ||
| LocalSettings.php 设置: | |||
| < | : <syntaxhighlight lang="PHP" highlight=""> | ||
| unset($wgFooterIcons['poweredby']); | |||
| </syntaxhighlight> | |||
| === 修改:皮肤 === | |||
|  MediaWiki 的皮肤位于“./skins”中,可在网络下载并上传至服务器中(注意:修改皮肤文件读写权限及所有者)。 | |||
|  <span style="color: blue">'''$wgDefaultSkin'''</span> 用于加载皮肤,<span style="color: blue">'''$wgDefaultSkin'''</span> 用于设置皮肤。 | |||
| LocalSettings.php 设置: | |||
| < | : <syntaxhighlight lang="PHP" highlight=""> | ||
| ## Default skin: you can change the default skin. Use the internal symbolic | |||
| ## names, ie 'vector', 'monobook', 'timeless': | |||
| $wgDefaultSkin = "vector"; | |||
| # Enabled skins. | |||
| # The following skins were automatically enabled: | |||
| wfLoadSkin( 'MinervaNeue' ); | |||
| wfLoadSkin( 'MonoBook' ); | |||
| wfLoadSkin( 'Timeless' ); | |||
| wfLoadSkin( 'Vector' ); | |||
| </syntaxhighlight> | |||
| ===  | === 配置:上传文件限制<ref>参考:[https://www.mediawiki.org/wiki/Manual:Configuring_file_uploads Manual:Configuring file uploads]</ref> === | ||
|  DefaultSettings.php 中设置了: | |||
|  1、默认允许上传的文件类型;(<span style="color: blue">'''png,gif,jpg,jpeg,webp'''</span>) | |||
|  2、默认不允许上传的文件类型;(“'''$wgProhibitedFileExtensions'''”在 1.37 版本之前为“'''$wgFileBlacklist'''”) | |||
| DefaultSettings.php:【不建议更改】 | |||
| : <syntaxhighlight lang="PHP" highlight=""> | |||
| /** | |||
|  * This is the list of preferred extensions for uploading files. Uploading files | |||
|  * with extensions not in this list will trigger a warning. | |||
|  * | |||
|  * @warning If you add any OpenOffice or Microsoft Office file formats here, | |||
|  * such as odt or doc, and untrusted users are allowed to upload files, then | |||
|  * your wiki will be vulnerable to cross-site request forgery (CSRF). | |||
|  */ | |||
| $wgFileExtensions = [ 'png', 'gif', 'jpg', 'jpeg', 'webp' ]; | |||
| /** | |||
|  * Files with these extensions will never be allowed as uploads. | |||
|  * An array of file extensions to prevent being uploaded. You should | |||
|  * append to this array if you want to prevent additional file extensions. | |||
|  * | |||
|  * @since 1.37; previously $wgFileBlacklist | |||
|  */ | |||
| $wgProhibitedFileExtensions = [ | |||
| 	# HTML may contain cookie-stealing JavaScript and web bugs | |||
| 	'html', 'htm', 'js', 'jsb', 'mhtml', 'mht', 'xhtml', 'xht', | |||
| 	# PHP scripts may execute arbitrary code on the server | |||
| 	'php', 'phtml', 'php3', 'php4', 'php5', 'phps', 'phar', | |||
| 	# Other types that may be interpreted by some servers | |||
| 	'shtml', 'jhtml', 'pl', 'py', 'cgi', | |||
| 	# May contain harmful executables for Windows victims | |||
| 	'exe', 'scr', 'dll', 'msi', 'vbs', 'bat', 'com', 'pif', 'cmd', 'vxd', 'cpl' | |||
| ]; | |||
| </syntaxhighlight> | |||
|  LocalSettings.php 中可以: | |||
|  1、开启文件上传; | |||
|  2、增加文件类型;    —— <span style="color: blue">'''可以与 DefaultSettings.php 类似地增加“允许的”、“不允许的”文件类型。'''</span> | |||
| LocalSettings.php:【可以更改】 | |||
| : <syntaxhighlight lang="PHP" highlight=""> | |||
| ... | |||
| $wgEnableUploads = true; | |||
| ... | |||
| $wgFileExtensions[] = 'svg'; | |||
| $wgFileExtensions[] = 'pdf'; | |||
| = | </syntaxhighlight> | ||
|  设置后: | |||
|  1、可以通过导航栏或特殊页面中的上传文件链接上传文件。 | |||
|  2、可以用 <code><span style="color: blue"><nowiki>[[File:文件名]]</nowiki></span></code> 在页面中引用文件  | |||
|      —— 如果引入的是图片文件,还可以指定图片宽度:<code><span style="color: blue"><nowiki>[[File:Example.jpg|200px]]</nowiki></span></code>,加入图片说明:<code><span style="color: blue"><nowiki>[[File:Example.jpg|图片1]]</nowiki></span></code>,设置方框效果:<code><span style="color: blue"><nowiki>[[File:Filename.jpg|thumb]]</nowiki></span></code>。 | |||
| </ | |||
| === | === 清除页面缓存 === | ||
|  '''DefaultSettings.php''' 中,找到参数 <span style="color: blue">'''$wgCacheEpoch'''</span>,将参数值置为服务器的当前时间,可以取消全部已经缓存的页面(包括客户端和服务器端)。 | |||
| $ | |||
| DefaultSettings.php 设置: | |||
| : <syntaxhighlight lang="PHP" highlight=""> | |||
| /** | |||
|  * Set this to current time to invalidate all prior cached pages. Affects both | |||
|  * client-side and server-side caching. | |||
|  * You can get the current date on your server by using the command: | |||
|  * @verbatim | |||
|  *   date +%Y%m%d%H%M%S | |||
|  * @endverbatim | |||
|  */ | |||
| $wgCacheEpoch = '20030516000000'; | |||
| $ | </syntaxhighlight> | ||
| </ | |||
| ====  | == 其他配置 == | ||
| < | === 修改:用户组 === | ||
|  MediaWiki 中有3个用户组:<span style="color: blue">'''机器人'''</span> / <span style="color: blue">'''管理员'''</span> / <span style="color: blue">'''行政员'''</span>,每个用户组的具体权限可通过“<span style="color: green">'''特殊页面 -> 用户组权限'''</span>”查看; | |||
|  Note: | |||
|  1、通过首页中“创建用户”注册的用户默认不属于任何用户组; | |||
|  2、从属于行政员用户组的用户,可通过“<span style="color: green">'''特殊页面 -> 用户权限管理'''</span>”给其他用户分配用户组。 | |||
| === 修改:左侧导航栏<ref>[[配置MW:左侧导航栏]]</ref> === | |||
| == 参考 == | |||
| <references/> | |||
| </ | |||
2022年8月23日 (二) 22:42的最新版本
配置文件
MediaWiki 的配置文件有两处: 1、DefaultSettings.php:系统默认的配置文件,位于“./includes/DefaultSettings.php”; 2、LocalSettings.php:用户设置的配置文件,位于“./LocalSettings.php”;
以下主要在 LocalSettings.php 中进行增加、覆盖、设置相应配置。
配置:短链接[1]
修改:Logo、Favicon
可以使用“Axialis IconWorkshop”制作图标(Favicon)。
LocalSettings.php 设置:
- ## The URL path to the logo. Make sure you change this from the default, ## or else you'll overwrite your logo when you upgrade! # $wgLogo = "$wgResourceBasePath/resources/assets/wiki.png"; # $wgLogos = [ '1x' => "$wgResourceBasePath/resources/assets/wiki.png" ]; $wgLogo = "$wgResourceBasePath/resources/assets/wikioe.png"; $wgFavicon = "$wgResourceBasePath/resources/assets/wikioe.ico"; 
修改:移除底部的“Powered by”图标
LocalSettings.php 设置:
- unset($wgFooterIcons['poweredby']); 
修改:皮肤
MediaWiki 的皮肤位于“./skins”中,可在网络下载并上传至服务器中(注意:修改皮肤文件读写权限及所有者)。 $wgDefaultSkin 用于加载皮肤,$wgDefaultSkin 用于设置皮肤。
LocalSettings.php 设置:
- ## Default skin: you can change the default skin. Use the internal symbolic ## names, ie 'vector', 'monobook', 'timeless': $wgDefaultSkin = "vector"; # Enabled skins. # The following skins were automatically enabled: wfLoadSkin( 'MinervaNeue' ); wfLoadSkin( 'MonoBook' ); wfLoadSkin( 'Timeless' ); wfLoadSkin( 'Vector' ); 
配置:上传文件限制[2]
DefaultSettings.php 中设置了:
1、默认允许上传的文件类型;(png,gif,jpg,jpeg,webp)
2、默认不允许上传的文件类型;(“$wgProhibitedFileExtensions”在 1.37 版本之前为“$wgFileBlacklist”)
DefaultSettings.php:【不建议更改】
- /** * This is the list of preferred extensions for uploading files. Uploading files * with extensions not in this list will trigger a warning. * * @warning If you add any OpenOffice or Microsoft Office file formats here, * such as odt or doc, and untrusted users are allowed to upload files, then * your wiki will be vulnerable to cross-site request forgery (CSRF). */ $wgFileExtensions = [ 'png', 'gif', 'jpg', 'jpeg', 'webp' ]; /** * Files with these extensions will never be allowed as uploads. * An array of file extensions to prevent being uploaded. You should * append to this array if you want to prevent additional file extensions. * * @since 1.37; previously $wgFileBlacklist */ $wgProhibitedFileExtensions = [ # HTML may contain cookie-stealing JavaScript and web bugs 'html', 'htm', 'js', 'jsb', 'mhtml', 'mht', 'xhtml', 'xht', # PHP scripts may execute arbitrary code on the server 'php', 'phtml', 'php3', 'php4', 'php5', 'phps', 'phar', # Other types that may be interpreted by some servers 'shtml', 'jhtml', 'pl', 'py', 'cgi', # May contain harmful executables for Windows victims 'exe', 'scr', 'dll', 'msi', 'vbs', 'bat', 'com', 'pif', 'cmd', 'vxd', 'cpl' ]; 
LocalSettings.php 中可以:
1、开启文件上传;
2、增加文件类型;    —— 可以与 DefaultSettings.php 类似地增加“允许的”、“不允许的”文件类型。
LocalSettings.php:【可以更改】
- ... $wgEnableUploads = true; ... $wgFileExtensions[] = 'svg'; $wgFileExtensions[] = 'pdf'; 
设置后: 1、可以通过导航栏或特殊页面中的上传文件链接上传文件。 2、可以用[[File:文件名]]在页面中引用文件 —— 如果引入的是图片文件,还可以指定图片宽度:[[File:Example.jpg|200px]],加入图片说明:[[File:Example.jpg|图片1]],设置方框效果:[[File:Filename.jpg|thumb]]。
清除页面缓存
DefaultSettings.php 中,找到参数 $wgCacheEpoch,将参数值置为服务器的当前时间,可以取消全部已经缓存的页面(包括客户端和服务器端)。
DefaultSettings.php 设置:
- /** * Set this to current time to invalidate all prior cached pages. Affects both * client-side and server-side caching. * You can get the current date on your server by using the command: * @verbatim * date +%Y%m%d%H%M%S * @endverbatim */ $wgCacheEpoch = '20030516000000'; 
其他配置
修改:用户组
MediaWiki 中有3个用户组:机器人 / 管理员 / 行政员,每个用户组的具体权限可通过“特殊页面 -> 用户组权限”查看; Note: 1、通过首页中“创建用户”注册的用户默认不属于任何用户组; 2、从属于行政员用户组的用户,可通过“特殊页面 -> 用户权限管理”给其他用户分配用户组。