“安装MW:初始化配置”的版本间差异
跳到导航
跳到搜索
无编辑摘要 |
无编辑摘要 |
||
第9行: | 第9行: | ||
2、<span style="color: blue; font-size: 150%">'''LocalSettings.php'''</span>:用户设置的配置文件,位于“<span style="color: green">'''./LocalSettings.php'''</span>”; | 2、<span style="color: blue; font-size: 150%">'''LocalSettings.php'''</span>:用户设置的配置文件,位于“<span style="color: green">'''./LocalSettings.php'''</span>”; | ||
以下主要在 '''LocalSettings.php''' 中进行增加、覆盖、设置相应配置。 | |||
=== 修改默认 Logo 与 Favicon === | === 修改默认 Logo 与 Favicon === | ||
可以使用“<span style="color: green; font-size: 120%">'''Axialis IconWorkshop'''</span>”制作图标(Favicon)。 | 可以使用“<span style="color: green; font-size: 120%">'''Axialis IconWorkshop'''</span>”制作图标(Favicon)。 | ||
设置: | LocalSettings.php 设置: | ||
: <syntaxhighlight lang="PHP" highlight=""> | : <syntaxhighlight lang="PHP" highlight=""> | ||
## The URL path to the logo. Make sure you change this from the default, | ## The URL path to the logo. Make sure you change this from the default, | ||
第25行: | 第25行: | ||
=== 去除底部的“Powered by”图标 === | === 去除底部的“Powered by”图标 === | ||
设置: | LocalSettings.php 设置: | ||
: <syntaxhighlight lang="PHP" highlight=""> | : <syntaxhighlight lang="PHP" highlight=""> | ||
unset($wgFooterIcons['poweredby']); | unset($wgFooterIcons['poweredby']); | ||
第35行: | 第35行: | ||
<span style="color: blue">'''$wgDefaultSkin'''</span> 用于加载皮肤,<span style="color: blue">'''$wgDefaultSkin'''</span> 用于设置皮肤。 | <span style="color: blue">'''$wgDefaultSkin'''</span> 用于加载皮肤,<span style="color: blue">'''$wgDefaultSkin'''</span> 用于设置皮肤。 | ||
设置: | LocalSettings.php 设置: | ||
: <syntaxhighlight lang="PHP" highlight=""> | : <syntaxhighlight lang="PHP" highlight=""> | ||
## Default skin: you can change the default skin. Use the internal symbolic | ## Default skin: you can change the default skin. Use the internal symbolic | ||
第50行: | 第50行: | ||
=== 上传文件配置 === | === 上传文件配置 === | ||
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', | 'html', 'htm', 'js', 'jsb', 'mhtml', 'mht', 'xhtml', 'xht', | ||
# PHP scripts may execute arbitrary code on the server | # PHP scripts may execute arbitrary code on the server | ||
第67行: | 第81行: | ||
'shtml', 'jhtml', 'pl', 'py', 'cgi', | 'shtml', 'jhtml', 'pl', 'py', 'cgi', | ||
# May contain harmful executables for Windows victims | # May contain harmful executables for Windows victims | ||
'exe', 'scr', 'dll', 'msi', 'vbs', 'bat', 'com', 'pif', 'cmd', 'vxd', 'cpl' ]; | '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 中,找到参数 | '''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 | * Set this to current time to invalidate all prior cached pages. Affects both | ||
第83行: | 第120行: | ||
*/ | */ | ||
$wgCacheEpoch = '20030516000000'; | $wgCacheEpoch = '20030516000000'; | ||
</ | </syntaxhighlight> | ||
== 其他配置 == | == 其他配置 == | ||
第107行: | 第144行: | ||
== 问题 == | -== 问题 == | ||
=== 站点路径的问题: === | === 站点路径的问题: === |
2022年8月22日 (一) 09:10的版本
配置文件
MediaWiki 的配置文件有两处: 1、DefaultSettings.php:系统默认的配置文件,位于“./includes/DefaultSettings.php”; 2、LocalSettings.php:用户设置的配置文件,位于“./LocalSettings.php”;
以下主要在 LocalSettings.php 中进行增加、覆盖、设置相应配置。
修改默认 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' );
上传文件配置
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';
其他配置
修改导航栏
通过wiki地址 index.php?title=MediaWiki( MediaWiki:Sidebar ),或者在搜索栏中输入“mediawiki:sidebar”,进入页面后点击编辑即可。
导航栏格式如下:
*导航栏名称一 **链接一地址|链接一名称 **链接二地址|链接二名称 *导航栏名称二 **链接一地址|链接一名称 **链接二地址|链接二名称
用户组
MediaWiki中有3个用户组:机器人/管理员/行政员,每个用户组的具体权限可通过”特殊页面” -> “用户组权限”查看;
通过首页中”创建用户”注册的用户默认不属于任何用户组;
从属于行政员用户组的用户,可通过”特殊页面” -> “用户权限管理”给其他用户分配用户组。
-== 问题 ==
站点路径的问题:
站点目录结构的不同,则配置文件的 $wgScriptPath
配置不同,网站的访问路径不同:
- 如果站点目录为
"/www/wwwroot/wiki.eijux.com/wiki"
:- LocalSettings.PHP的配置为:
$wgScriptPath = ""
; - 网站的访问路径为:
http://wiki.eijux.com/index.php?title=%E9%A6%96%E9%A1%B5
- LocalSettings.PHP的配置为:
- 如果站点目录为
"/www/wwwroot/wiki.eijux.com/wiki"
:- LocalSettings.PHP的配置为:
$wgScriptPath = "/wiki"
; - 网站的访问路径为:
http://wiki.eijux.com/wiki/index.php?title=%E9%A6%96%E9%A1%B5
- LocalSettings.PHP的配置为: