root@Ubuntu1804-aliyun:~# apt-get install php php-xml php-mbstring php-mysql mysql-server
安装完成后重启apache服务器
root@Ubuntu1804-aliyun:~# /etc/init.d/apache2 restart
将下载的mediawiki-1.33.0.tar.gz 解压 拷贝到/var/www/html/
root@Ubuntu1804-aliyun:~# tar zxvf mediawiki-1.33.0.tar.gz
root@Ubuntu1804-aliyun:~# mv mediawiki-1.33.0 wiki
root@Ubuntu1804-aliyun:~# mv wiki /var/www/html
root@Ubuntu1804-aliyun:~# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.26-0ubuntu0.18.04.1 (Ubuntu)
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> CREATE USER 'admin'@'localhost' IDENTIFIED BY 'admin.123';
Query OK, 0 rows affected (0.00 sec)
mysql> quit;
Bye
root@Ubuntu1804-aliyun:~# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.26-0ubuntu0.18.04.1 (Ubuntu)
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> CREATE DATABASE my_wiki;
Query OK, 1 row affected (0.00 sec)
mysql> use my_wiki;
Database changed
mysql> GRANT ALL ON my_wiki.* TO 'admin'@'localhost';
Query OK, 0 rows affected (0.00 sec)
mysql> quit;
Bye
浏览器登录http://39.106.45.177/wiki 按照步骤提示操作,点击set up the wiki
mysql配置这里比较关键,设置如下。
wiki 名称及管理员账户设置,这里根据自己需求实际设置,然后可选择我不耐烦了,完成配置。
接下来会弹出“恭喜! 您已经安装了MediaWiki。“
点击上图“进入您的wiki”,或者访问http://39.106.45.177/wiki ,如下图。
默认安装完任何用户都可注册,编辑,这里我们设置阻止新用户注册及未登录用户可浏览,但不能编辑。
在LocalSettings.php 末端加上下面语句。
# Prevent new user registrations 阻止新用户注册
$wgGroupPermissions['*' ]['createaccount'] = false;
# 设置匿名用户(未登录用户)可浏览,但不能编辑
$wgGroupPermissions['*' ]['read'] = true;
$wgGroupPermissions['*' ]['edit'] = false;
可视化编辑器可方便用户编辑wiki,这个工具安装比较复杂,需要依赖于Parsoid。
在https://extdist.wmflabs.org/dist/extensions/网站找到最新的visualEditor,这里使用的版本是VisualEditor-REL1_33-8c9c37e.tar.gz。下载下来,解压,拷贝到/var/www/html/wiki/extensions下。
root@Ubuntu1804-aliyun:~# tar zxvf VisualEditor-REL1_33-8c9c37e.tar.gz
root@Ubuntu1804-aliyun:~# mv VisualEditor /var/www/html/wiki/extensions
在LocalSettings.php 末端加上下面语句。
wfLoadExtension( 'VisualEditor' );
// Enable by default for everybody
$wgDefaultUserOptions['visualeditor-enable'] = 1;
// Optional: Set VisualEditor as the default for anonymous users
// otherwise they will have to switch to VE
// $wgDefaultUserOptions['visualeditor-editor'] = "visualeditor";
// Don't allow users to disable it
$wgHiddenPrefs[] = 'visualeditor-enable';
// OPTIONAL: Enable VisualEditor's experimental code features
#$wgDefaultUserOptions['visualeditor-enable-experimental'] = 1;
parsoid依赖npm,首先需要安装npm。
root@Ubuntu1804-aliyun:~# apt-get install nodejs npm
git clone https://github.com/wikimedia/parsoid.git
cd parsoid
npm install
配置parsoid,拷贝config.example.yaml到config.yaml,并修改config.yaml文件。
cp config.example.yaml config.yaml
config.yaml文件主要修改一下几条:
uri: 'https://39.106.45.177/wiki/api.php'
domain: 'localhost' # optional
serverPort: 8000
serverInterface: '127.0.0.1'
运行parsoid,命令为nohup node bin/server.js &。
nohup node bin/server.js &
注意这里,主机重启或开机都需要运行parsoid,否则 VisualEditor 无法使用。
到这里,还需要使MediaWiki可以找到parsoid,编辑/var/www/html/wiki/LocalSettings.php,追加如下内容:
$wgVirtualRestConfig['modules']['parsoid'] = array(
'url' => 'http://localhost:8000',
'domain' => 'localhost',
'prefix' => 'localhost'
);
此时,我们可以通过wiki页面编辑使用VisualEditor,效果如图所示。
扩展 | 下载地址 | 使用版本 |
---|---|---|
SyntaxHighlight_GeSHi语法高亮(默认extensions有,可不用下载) | https://www.mediawiki.org/wiki/Special:ExtensionDistributor/SyntaxHighlight_GeSHi | SyntaxHighlight_GeSHi-REL1_32-715c3e0.tar.gz |
Math 数学公式 | https://www.mediawiki.org/wiki/Special:ExtensionDistributor/Math | Math-REL1_32-b976708.tar.gz |
Graph 图表 | https://www.mediawiki.org/wiki/Special:ExtensionDistributor/Graph | Math-REL1_32-b976708.tar.gz |
从上表地址中下载,分别放放到/var/www/html/wiki/extensions目录下。
并在LocalSettings.php 末端加上下面语句。
wfLoadExtension( 'SyntaxHighlight_GeSHi' );
wfLoadExtension( 'Math' );
wfLoadExtension( 'Graph' );
Mediawiki 已经不推荐使用删除用户(Deleteuser),推荐使用用户合并(UserMerge)方式。
用户合并(UserMerge)扩展允许有“usermerge”权限的wiki用户(默认为行政员)合并一个Wiki用户账户至另一个Wiki用户账户。
wfLoadExtension( 'UserMerge' );
// By default nobody can use this function, enable for bureaucrat?
$wgGroupPermissions['bureaucrat']['usermerge'] = true;
// optional: default is array( 'sysop' )
$wgUserMergeProtectedGroups = array( 'groupname' );
管理员用户可在特殊页面找到“用户合并和删除”,点击进入页面进行操作。
待续。
参考文档:
[1]: https://www.mediawiki.org/wiki/Manual:Running_MediaWiki_on_Debian_or_Ubuntu/zh
[2]:http://wangyapeng.me/2017/05/14/unbuntu-setup-mediawiki/
[3]:https://www.mediawiki.org/wiki/Extension:VisualEditor/pl
[4]:https://www.mediawiki.org/wiki/Extension:UserMerge/zh#Installation