一、wiki基础环境 LNMP环境 搭建(请查看其他几篇日志):
由于我是离线编译安装,所以过程比较曲折,通过几篇日志分别记录了 安装 php、apache2、mysql等操作要点:
apache2: https://blog.csdn.net/zzddada/article/details/108222478
php: https://blog.csdn.net/zzddada/article/details/108239847
https://blog.csdn.net/zzddada/article/details/108327839
mysql:(省略)
注: 注意apache和php版本的匹配
二、wiki安装
1、下载mediawiki
下载地址:https://www.mediawiki.org/wiki/Download
wget https://releases.wikimedia.org/mediawiki/1.34/mediawiki-1.34.0.tar.gz
linux不能访问外网,下载慢就用浏览器下载
解压,修改文件名(去掉版本号)
tar xvf mediawiki-1.31.1.tar.gz
mv mediawiki-1.31.1/ mediawiki/
将其放到apache2的 服务器默认主目录下 或 你定义的默认目录下
(我的apache2 原默认目录是 /usr/local/apache/htdocs 根据安装的不同默认根目录会有不同)
mv mediawiki/ /usr/local/apache/htdocs/mediawiki
注:domain可以是域名或ip地址,比如 http://192.168.10.10/mediawiki/
在浏览器中输入 http://domain/mediawiki/
会进入 mediawiki 文件根目录(可以看到 放在apache默认访问路径的下的 mediawiki 文件内容)
wiki目录结构:
其中 :
extensions 扩展包存储目录,在安装时,或自动检索加载到安装的可选项中;
resources 存储用到的静态图片、图标
2、下载mediawiki 拓展包 存放到 wiki 的 extensions目录下
所有扩展包可在以下目录查看:
3、继续访问 http://domain/mediawiki/index.php 进入安装页面,
选择安装配置所有的语言,这里都选中文简体(zh-hans);
配置 LocalSettings.php 中内容如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204<?php # This file was automatically generated by the MediaWiki 1.34.2 # installer. If you make manual changes, please keep track in case you # need to recreate them later. # # See includes/DefaultSettings.php for all configurable settings # and their default values, but don't forget to make changes in _this_ # file, not there. # # Further documentation for configuration settings may be found at: # https://www.mediawiki.org/wiki/Manual:Configuration_settings # Protect against web entry if ( !defined( 'MEDIAWIKI' ) ) { exit; } ## --------------------------- ## 禁止新用户注册 Prevent new user registrations $wgWhitelistAccount = array ( "user" => 0, "sysop" => 1, "developer" => 1 ); ## 设置匿名用户:不可创建账号、不可编辑、可读 ## $wgGroupPermissions = array(); $wgGroupPermissions['*']['createaccount'] = false; $wgGroupPermissions['*']['read'] = true; $wgGroupPermissions['*']['edit'] = false; ## 限制非注册用户不可读 ## $wgWhitelistRead = array( "Main Page", "Special:Userlogin", "-", "MediaWiki:Monobook.css" ); ## $wgGroupPermissions['*']['read'] = false; ## 设定匿名用户(未登录)可以看到的页面 ## $wgWhitelistRead = array ("Main Page", "Special:Userlogin", "Wikipedia:Help"); ## 上面是:匿名用户只能看到Main Page、登录页面以及帮助页面。 ## ---------------------------------- ## 以下配置可以解决 报错: $wgSessionInsecureSecrets = true; ## 缓存相关的设置 $wgShowExceptionDetails = true; ## 打印查看具体的报错信息 ## ---------------------------------- ## Uncomment this to disable output compression # $wgDisableOutputCompression = true; $wgSitename = "这是网站名称"; ## The URL base path to the directory containing the wiki; ## defaults for all runtime URL paths are based off of this. ## For more information on customizing the URLs ## (like /w/index.php/Page_title to /wiki/Page_title) please see: ## https://www.mediawiki.org/wiki/Manual:Short_URL $wgScriptPath = "/mediawiki"; ## The protocol and server name to use in fully-qualified URLs $wgServer = "http://192.168.35.11"; ## The URL path to static resources (images, scripts, etc.) $wgResourceBasePath = $wgScriptPath; ## 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"; ## UPO means: this is also a user preference option $wgEnableEmail = false; $wgEnableUserEmail = true; # UPO $wgEmergencyContact = "apache@????.invalid"; $wgPasswordSender = "apache@????.invalid"; $wgEnotifUserTalk = false; # UPO $wgEnotifWatchlist = false; # UPO $wgEmailAuthentication = true; ## Database settings $wgDBtype = "mysql"; $wgDBserver = "192.168.32.57:31306"; $wgDBname = "wiki_csljc"; $wgDBuser = "root"; $wgDBpassword = "0000abc!"; # MySQL specific settings $wgDBprefix = "wiki"; # MySQL table options to use during installation or update $wgDBTableOptions = "ENGINE=InnoDB, DEFAULT CHARSET=binary"; ## Shared memory settings $wgMainCacheType = CACHE_NONE; $wgMemCachedServers = []; ## To enable image uploads, make sure the 'images' directory ## is writable, then set this to true: $wgEnableUploads = true; $wgUseImageMagick = true; $wgImageMagickConvertCommand = "/usr/bin/convert"; # InstantCommons allows wiki to use images from https://commons.wikimedia.org $wgUseInstantCommons = false; # Periodically send a pingback to https://www.mediawiki.org/ with basic data # about this MediaWiki instance. The Wikimedia Foundation shares this data # with MediaWiki developers to help guide future development efforts. $wgPingback = true; ## If you use ImageMagick (or any other shell command) on a ## Linux server, this will need to be set to the name of an ## available UTF-8 locale $wgShellLocale = "en_US.utf8"; ## Set $wgCacheDirectory to a writable directory on the web server ## to make your wiki go slightly faster. The directory should not ## be publicly accessible from the web. #$wgCacheDirectory = "$IP/cache"; # Site language code, should be one of the list in ./languages/data/Names.php $wgLanguageCode = "zh-cn"; $wgSecretKey = "862fa4d61cb5c19dcb8d838bb94c8c399fd244e1758fabc895fa2795bf9ac2f1"; # Changing this will log out all existing sessions. $wgAuthenticationTokenVersion = "1"; # Site upgrade key. Must be set to a string (default provided) to turn on the # web installer while LocalSettings.php is in place $wgUpgradeKey = "d38658fc116454ff"; ## For attaching licensing metadata to pages, and displaying an ## appropriate copyright notice / icon. GNU Free Documentation ## License and Creative Commons licenses are supported so far. $wgRightsPage = ""; # Set to the title of a wiki page that describes your license/copyright $wgRightsUrl = ""; $wgRightsText = ""; $wgRightsIcon = ""; # Path to the GNU diff3 utility. Used for conflict resolution. $wgDiff3 = "/usr/bin/diff3"; ## Default skin: you can change the default skin. Use the internal symbolic ## names, ie 'vector', 'monobook': $wgDefaultSkin = "vector"; # Enabled skins. # The following skins were automatically enabled: wfLoadSkin( 'MonoBook' ); wfLoadSkin( 'Timeless' ); wfLoadSkin( 'Vector' ); # Enabled extensions. Most of the extensions are enabled by adding # wfLoadExtensions('ExtensionName'); # to LocalSettings.php. Check specific extension documentation for more details. # The following extensions were automatically enabled: ## 设置需要加载的扩展包 wfLoadExtension( 'Avatar' ); wfLoadExtension( 'CategoryTree' ); wfLoadExtension( 'Cite' ); wfLoadExtension( 'CiteThisPage' ); wfLoadExtension( 'CodeEditor' ); wfLoadExtension( 'CodeMirror' ); # wfLoadExtension( 'ConfirmEdit' ); wfLoadExtension( 'Echo' ); wfLoadExtension( 'FlowThread' ); wfLoadExtension( 'Gadgets' ); wfLoadExtension( 'ImageMap' ); wfLoadExtension( 'intersection' ); wfLoadExtension( 'Interwiki' ); wfLoadExtension( 'LocalisationUpdate' ); wfLoadExtension( 'Loops' ); wfLoadExtension( 'Math' ); wfLoadExtension( 'MsUpload' ); wfLoadExtension( 'MultimediaViewer' ); wfLoadExtension( 'Nuke' ); # wfLoadExtension( 'OATHAuth' ); wfLoadExtension( 'PageImages' ); wfLoadExtension( 'ParserFunctions' ); wfLoadExtension( 'PdfHandler' ); wfLoadExtension( 'Poem' ); wfLoadExtension( 'Popups' ); wfLoadExtension( 'RelatedArticles' ); wfLoadExtension( 'Renameuser' ); wfLoadExtension( 'ReplaceText' ); wfLoadExtension( 'RevisionSlider' ); wfLoadExtension( 'Scribunto' ); wfLoadExtension( 'SpamBlacklist' ); wfLoadExtension( 'SyntaxHighlight_GeSHi' ); wfLoadExtension( 'Tabber' ); wfLoadExtension( 'TemplateStyles' ); wfLoadExtension( 'TextExtracts' ); wfLoadExtension( 'Thanks' ); wfLoadExtension( 'TitleBlacklist' ); wfLoadExtension( 'WikiEditor' ); # End of automatically generated settings. # Add more configuration options below.
以上 “ #------- ” 标注的内容是我添加的设置(具体作用看上面注释)
4、更新扩展包,重新加载生成wiki依赖包所需的数据库表
访问wiki根目录,进入 http://domain/mediawiki/mw-config/index.php
会进入以下页面,
输入密钥即可,即可自动加载新加的扩展包,并生成相关数据库等等;
(然而我并没有成功生成依赖包所需的数据库,最终是通过 执行 依赖包携带的 sql文件来生成的数据库表)
5、设置服务器上的 目录读写权限 ,我比较暴力直接都改为 777
6、添加文件上传功能,在 localsettings.php 检查一下配置中:
在 localsettings.php 中:
$wgEnableUploads = true; ## 允许上传
$wgUploadPath = "$wgScriptPath/uploads"; ## 默认为 "$wgScriptPath/images" ,请确保目录可写
$wgUploadDirectory = "$IP/uploads"; ## 默认为 "$wgScriptPath/images"
$wgMaxUploadSize = 20000000; ## 20M 上传文件尺寸上限
$wgUploadSizeWarning = 10000000; ## 10M 上传文件尺寸超过该值,则警告
##允许上传文件的扩展名
$wgFileExtensions = array('png','jpg','jpeg','gif','ogg','doc','docx','xls','xlsx','ppt','pptx','mp3','sxc','pdf','nse');##安全的文件上传模式,文件不是直接放在 UploadPath下,而是它下面的一些随机生成的子目录中。
$wgHashedUploadDirectory = true;
在 php.ini 中:修改文件上传相关的参数:
memory_limit = 256 M
post_max_size = 25M
upload_max_filesize = 20M
总的原则是 memory_limit > post_max_size > upload_max_filesize > wgMaxUploadSize > UploadSizeWarning
6、设置apache默认访问页面、禁止访问目录等等操作 (比较简单,忽略)
(1)apache 设置默认页面(以apache默认目录为路径起点)
apache的 httpd.conf 中
<IfModule dir_module>
DirectoryIndex mediawiki/index.php
</IfModule>
7、补充:
以下代码增加的位置:LocalSettins.php
因为require_once( "includes/DefaultSettings.php" )中初始化过,所以下面语句必须放在此语句之后。
禁止新用户注册
在LocalSettings.php中加入:
#Prevent new user registrations
$wgWhitelistAccount = array ( "user" => 0, "sysop" => 1, "developer" => 1 );
此时用户无法自助注册。管理员可以到登录页面(Special:UserLogin)里,输入一个用户名和email,然后点击“by email”,系统创建帐号并将随机密码发送到指定email里。
禁止匿名用户编辑
#$wgGroupPermissions = array();
$wgGroupPermissions['*''createaccount'] = false;
$wgGroupPermissions['*']['read'] = true;
$wgGroupPermissions['*']['edit'] = false;
“编辑”标签仍会显示,但匿名用户点击时会被提示要求进行登录。
等式右侧的值决定各组成员的权限。左侧第一方括号内的'*'代表包括匿名用户在内的所有成员。登录用户控制存放在'user'组,这些将综合决定user_groups数据表中的成员权限。
这些设置取代了以前的wgWhitelistAccount和wgWhitelistEdit。
如此设定后,用户连首页和登录页面也看不到了。
///限制非注册用户不可读
$wgWhitelistRead = array( "Main Page", "Special:Userlogin", "-", "MediaWiki:Monobook.css" );
$wgGroupPermissions['*']['read'] = false;
///限制非注册用户不可读
设定匿名用户(未登录)可以看到的页面
$wgWhitelistRead = array ("Main Page", "Special:Userlogin", "Wikipedia:Help");匿名用户只能看到Main Page、登录页面以及帮助页面。
修改其他的例子:
$wgWhitelistRead = array ("首页", "Special:Userlogin", "某某Wiki:Help");
$wgWhitelistRead = array( urldecode("%E9%A6%96%E9%A1%B5") ;
对于多字节语言(例如中文),PHP parser可能不能正确解码,要用到PHP的urldecode()函数来转换。
三、报错解决:
1、用户登陆时报错 :PHP7.3、Mediawiki1.35出现:
Exception encountered, of type "BadMethodCallException"
解决方案:安装php-openssl或者php-mcrypt;实在无法安装在Localsettings.php开启
$wgSessionInsecureSecrets = true;
但不推荐。记录一下。
注意:php文件最好在编辑器中直接编辑,不知道为什么,存储到本地修改后再传上去服务器,就发生了报错 不知道为什么;
参考:http://blog.sciencenet.cn/blog-1750-1012598.html
2、账户登录时,报以下奇葩的错误:
Function: EchoEventMapper::fetchUnreadByUserAndPage Error: 1146 Table 'wiki.wikiecho_event' doesn't exist
分析原因:扩展包,需要添加几个数据库表,但是在安装时没有生成,(可能因为我的有些扩展包是下载后,拖放到extensions 进去的;但是在初始化生成 LocalSettings.php 时,也没有给我自动生成数据库表,比较纳闷??)
解决办法:
经高人指点,此依赖包有 随包携带的sql语句,可查看
/mediawiki/extensions/Echo/echo.sql
直接拷贝这个sql,到数据库执行即可生成;
(注:如果在前面设置时,我们有设置 默认的“ 表头前缀 ” ,需要在生成 echo相关表后,修改表名为符合我们前面设置的数据库表名;)
3、上传图片报错?多半是目录的读写权限问题,具体情况具体分析;
4、
MediaWiki internal error.
Original exception: [f344c9e7d25afbb628eb30ef] 2020-11-10 09:01:20: Fatal exception of type "WikimediaRdbmsDBQueryError"
Exception caught inside exception handler.
Set $wgShowExceptionDetails = true; at the bottom of LocalSettings.php to show detailed debugging information.
最后
以上就是闪闪皮皮虾最近收集整理的关于Wiki安装:mediawiki-1.34.2 安装配置一、wiki基础环境 LNMP环境 搭建(请查看其他几篇日志):二、wiki安装三、报错解决:的全部内容,更多相关Wiki安装:mediawiki-1.34.2内容请搜索靠谱客的其他文章。
发表评论 取消回复