安装MW:初始化配置

来自Wikioe
跳到导航 跳到搜索


配置文件

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、从属于行政员用户组的用户,可通过“特殊页面 -> 用户权限管理”给其他用户分配用户组。

修改:左侧导航栏[3]

参考