前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Install MediaWiki

Install MediaWiki

作者头像
franket
发布2021-08-11 09:38:32
1K0
发布2021-08-11 09:38:32
举报
文章被收录于专栏:技术杂记

前言

MediaWiki 是一款用 php 实现的开源 wiki 软件

MediaWiki is a free software open source wiki package written in PHP, originally for use on Wikipedia. It is now also used by several other projects of the non-profit Wikimedia Foundation and by many other wikis, including this website, the home of MediaWiki.

作为一种具备开源精神的知识共享平台,wiki 在全世界都广受欢迎

使用 MediaWiki 可以在组织内部构建一个信息共享平台,用于知识分享

在技术型组织里,可以使用它来构建一个词条文档管理系统

这里演示一下如何构建 MediaWiki

参考:

Running MediaWiki on Red Hat Linux

Installation guide

Installing MediaWiki

Tip: 当前的版本为 MediaWiki 1.30.0


操作

依赖

  • Web server such as Apache or IIS
    • Local or command line access is needed for running maintenance scripts
  • PHP version 5.5.9 or later
    • with Perl Compatible Regular Expressions
    • with Standard PHP Library
    • with JSON support
  • Database Server, one of the following:
    • MySQL 5.5.8+ (*)
    • MariaDB
    • PostgreSQL 8.3+
    • SQLite

详细依赖可以参考 Installation requirements

环境

代码语言:javascript
复制
[root@wiki ~]# cat /etc/centos-release
CentOS Linux release 7.4.1708 (Core) 
[root@wiki ~]# hostnamectl 
   Static hostname: wiki
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 316348df30744c9c91b9202baf3915a6
           Boot ID: d7231d0112bb46d88ed5bc34302d88e1
    Virtualization: kvm
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-693.21.1.el7.x86_64
      Architecture: x86-64
[root@wiki ~]# ip a 
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:8c:97:19 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic enp0s3
       valid_lft 72852sec preferred_lft 72852sec
    inet6 fe80::334c:bc63:1266:56b3/64 scope link 
       valid_lft forever preferred_lft forever
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:ab:2c:0c brd ff:ff:ff:ff:ff:ff
    inet 192.168.56.214/24 brd 192.168.56.255 scope global enp0s8
       valid_lft forever preferred_lft forever
    inet6 fe80::2be7:a317:cc4b:666b/64 scope link 
       valid_lft forever preferred_lft forever
4: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN qlen 1000
    link/ether 52:54:00:14:54:5c brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
5: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 1000
    link/ether 52:54:00:14:54:5c brd ff:ff:ff:ff:ff:ff
[root@wiki ~]# 

软件环境

代码语言:javascript
复制
[root@wiki ~]# systemctl status mariadb.service
● mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
   Active: active (running) since 日 2018-04-15 06:00:03 EDT; 3h 46min ago
  Process: 1230 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS)
  Process: 1162 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
 Main PID: 1229 (mysqld_safe)
   CGroup: /system.slice/mariadb.service
           ├─1229 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
           └─1446 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log...

4月 15 06:00:01 wiki systemd[1]: Starting MariaDB database server...
4月 15 06:00:01 wiki mariadb-prepare-db-dir[1162]: Database MariaDB is probably initialized in /var/lib/mysql alre...done.
4月 15 06:00:01 wiki mariadb-prepare-db-dir[1162]: If this is not the case, make sure the /var/lib/mysql is empty ...-dir.
4月 15 06:00:01 wiki mysqld_safe[1229]: 180415 06:00:01 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
4月 15 06:00:02 wiki mysqld_safe[1229]: 180415 06:00:02 mysqld_safe Starting mysqld daemon with databases from /v.../mysql
4月 15 06:00:03 wiki systemd[1]: Started MariaDB database server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@wiki ~]# systemctl status httpd.service
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since 日 2018-04-15 06:00:02 EDT; 3h 46min ago
     Docs: man:httpd(8)
           man:apachectl(8)
 Main PID: 1180 (httpd)
   Status: "Total requests: 0; Current requests/sec: 0; Current traffic:   0 B/sec"
   CGroup: /system.slice/httpd.service
           ├─1180 /usr/sbin/httpd -DFOREGROUND
           ├─1419 /usr/sbin/httpd -DFOREGROUND
           ├─1420 /usr/sbin/httpd -DFOREGROUND
           ├─1421 /usr/sbin/httpd -DFOREGROUND
           ├─1422 /usr/sbin/httpd -DFOREGROUND
           └─1423 /usr/sbin/httpd -DFOREGROUND

4月 15 06:00:01 wiki systemd[1]: Starting The Apache HTTP Server...
4月 15 06:00:01 wiki httpd[1180]: AH00558: httpd: Could not reliably determine the server's fully qualified domai...essage
4月 15 06:00:02 wiki systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@wiki ~]# php --version
PHP 7.2.4 (cli) (built: Mar 27 2018 17:23:35) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.4, Copyright (c) 1999-2018, by Zend Technologies
[root@wiki ~]# 

依赖包安装

确认已经成功安装以下包

代码语言:javascript
复制
[root@wiki ~]# yum install httpd php php-mysql php-gd php-xml mariadb-server mariadb php-mbstring
Loaded plugins: fastestmirror, langpacks
base                                                                                                | 3.6 kB  00:00:00     
epel/x86_64/metalink                                                                                | 7.4 kB  00:00:00     
extras                                                                                              | 3.4 kB  00:00:00     
remi-php72                                                                                          | 2.9 kB  00:00:00     
remi-safe                                                                                           | 2.9 kB  00:00:00     
updates                                                                                             | 3.4 kB  00:00:00     
Loading mirror speeds from cached hostfile
 * base: mirror.pregi.net
 * epel: mirror.smartmedia.net.id
 * extras: mirror.pregi.net
 * remi-php72: mirrors.thzhost.com
 * remi-safe: mirrors.thzhost.com
 * updates: mirror.pregi.net
Package httpd-2.4.6-67.el7.centos.6.x86_64 already installed and latest version
Package php-7.2.4-1.el7.remi.x86_64 already installed and latest version
Package php-mysql-5.4.16-43.el7_4.1.x86_64 is obsoleted by php-mysqlnd-7.2.4-1.el7.remi.x86_64 which is already installed
Package php-gd-7.2.4-1.el7.remi.x86_64 already installed and latest version
Package php-xml-7.2.4-1.el7.remi.x86_64 already installed and latest version
Package 1:mariadb-server-5.5.56-2.el7.x86_64 already installed and latest version
Package 1:mariadb-5.5.56-2.el7.x86_64 already installed and latest version
Package php-mbstring-7.2.4-1.el7.remi.x86_64 already installed and latest version
Nothing to do
[root@wiki ~]# 

创建数据库和为用户分配权限

代码语言:javascript
复制
[root@wiki ~]# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.56-MariaDB MariaDB Server

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> CREATE USER 'wiki'@'localhost' IDENTIFIED BY 'wiki';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> CREATE DATABASE wiki_db;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON wiki_db.* TO 'wiki'@'localhost';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| wiki_db            |
+--------------------+
4 rows in set (0.00 sec)

MariaDB [(none)]> show create database wiki_db;
+----------+--------------------------------------------------------------------+
| Database | Create Database                                                    |
+----------+--------------------------------------------------------------------+
| wiki_db  | CREATE DATABASE `wiki_db` /*!40100 DEFAULT CHARACTER SET latin1 */ |
+----------+--------------------------------------------------------------------+
1 row in set (0.00 sec)

MariaDB [(none)]> SHOW GRANTS FOR 'wiki'@'localhost';
+-------------------------------------------------------------------------------------------------------------+
| Grants for wiki@localhost                                                                                   |
+-------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'wiki'@'localhost' IDENTIFIED BY PASSWORD '*A5DB2D927D6DF94DA5E1CE4B293AEAAB4D8304EA' |
| GRANT ALL PRIVILEGES ON `wiki_db`.* TO 'wiki'@'localhost'                                                   |
+-------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

MariaDB [(none)]> exit
Bye
[root@wiki ~]# 

下载 wikimedia 软件包

代码语言:javascript
复制
[root@wiki ~]# cd wiki/
[root@wiki wiki]# ls
[root@wiki wiki]# wget http://releases.wikimedia.org/mediawiki/1.30/mediawiki-1.30.0.tar.gz
--2018-04-15 10:13:59--  http://releases.wikimedia.org/mediawiki/1.30/mediawiki-1.30.0.tar.gz
Resolving releases.wikimedia.org (releases.wikimedia.org)... 208.80.153.248, 2620:0:860:ed1a::3:d
Connecting to releases.wikimedia.org (releases.wikimedia.org)|208.80.153.248|:80... connected.
HTTP request sent, awaiting response... 301 TLS Redirect
Location: https://releases.wikimedia.org/mediawiki/1.30/mediawiki-1.30.0.tar.gz [following]
--2018-04-15 10:14:00--  https://releases.wikimedia.org/mediawiki/1.30/mediawiki-1.30.0.tar.gz
Connecting to releases.wikimedia.org (releases.wikimedia.org)|208.80.153.248|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 42680041 (41M) [application/x-gzip]
Saving to: ‘mediawiki-1.30.0.tar.gz’

100%[=================================================================================>] 42,680,041  2.59MB/s   in 28s    

2018-04-15 10:14:29 (1.44 MB/s) - ‘mediawiki-1.30.0.tar.gz’ saved [42680041/42680041]

[root@wiki wiki]# ls
mediawiki-1.30.0.tar.gz
[root@wiki wiki]# 

解压 mediawiki 到合适的路径

代码语言:javascript
复制
[root@wiki wiki]# ls
mediawiki-1.30.0.tar.gz
[root@wiki wiki]# tar -zxf  mediawiki-1.30.0.tar.gz 
[root@wiki wiki]# ls
mediawiki-1.30.0  mediawiki-1.30.0.tar.gz
[root@wiki wiki]# cp -r mediawiki-1.30.0 /var/www/html/mediawiki
[root@wiki wiki]# 
[root@wiki wiki]# chown -R apache.apache /var/www/html/
[root@wiki wiki]# ll /var/www/html/mediawiki/
total 1184
-rw-r--r--  1 apache apache   4697 4月  15 10:22 api.php
-rw-r--r--  1 apache apache 131511 4月  15 10:22 autoload.php
drwxr-xr-x  2 apache apache     23 4月  15 10:22 cache
-rw-r--r--  1 apache apache    116 4月  15 10:22 CODE_OF_CONDUCT.md
-rw-r--r--  1 apache apache   3595 4月  15 10:22 composer.json
-rw-r--r--  1 apache apache    102 4月  15 10:22 composer.local.json-sample
-rw-r--r--  1 apache apache  19419 4月  15 10:22 COPYING
-rw-r--r--  1 apache apache  10924 4月  15 10:22 CREDITS
drwxr-xr-x  8 apache apache   4096 4月  15 10:22 docs
drwxr-xr-x 19 apache apache    334 4月  15 10:22 extensions
-rw-r--r--  1 apache apache     95 4月  15 10:22 FAQ
-rw-r--r--  1 apache apache   3735 4月  15 10:22 Gruntfile.js
-rw-r--r--  1 apache apache 867797 4月  15 10:22 HISTORY
drwxr-xr-x  2 apache apache     37 4月  15 10:22 images
-rw-r--r--  1 apache apache   7705 4月  15 10:22 img_auth.php
drwxr-xr-x 66 apache apache   8192 4月  15 10:22 includes
-rw-r--r--  1 apache apache   1623 4月  15 10:22 index.php
-rw-r--r--  1 apache apache   3663 4月  15 10:22 INSTALL
-rw-r--r--  1 apache apache   2025 4月  15 10:22 jsduck.json
drwxr-xr-x  6 apache apache    229 4月  15 10:22 languages
-rw-r--r--  1 apache apache   1965 4月  15 10:22 load.php
drwxr-xr-x 17 apache apache   8192 4月  15 10:22 maintenance
drwxr-xr-x  4 apache apache    110 4月  15 10:22 mw-config
-rw-r--r--  1 apache apache   4059 4月  15 10:22 opensearch_desc.php
-rw-r--r--  1 apache apache   3274 4月  15 10:22 phpcs.xml
-rw-r--r--  1 apache apache  12013 4月  15 10:22 profileinfo.php
-rw-r--r--  1 apache apache   1529 4月  15 10:22 README
-rw-r--r--  1 apache apache  16790 4月  15 10:22 RELEASE-NOTES-1.30
drwxr-xr-x  5 apache apache     63 4月  15 10:22 resources
drwxr-xr-x  2 apache apache    144 4月  15 10:22 serialized
drwxr-xr-x  6 apache apache     83 4月  15 10:22 skins
-rw-r--r--  1 apache apache   1703 4月  15 10:22 StartProfiler.sample
drwxr-xr-x  9 apache apache    126 4月  15 10:22 tests
-rw-r--r--  1 apache apache   1087 4月  15 10:22 thumb_handler.php
-rw-r--r--  1 apache apache  21335 4月  15 10:22 thumb.php
-rw-r--r--  1 apache apache  12244 4月  15 10:22 UPGRADE
drwxr-xr-x 22 apache apache   4096 4月  15 10:22 vendor
[root@wiki wiki]#

确认防火墙开放

代码语言:javascript
复制
[root@wiki wiki]# firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: enp0s3 enp0s8
  sources: 
  services: ssh dhcpv6-client http https
  ports: 
  protocols: 
  masquerade: no
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules: 
	
[root@wiki wiki]#

确认 SELINUX 放行

代码语言:javascript
复制
[root@wiki wiki]# getenforce 
Disabled
[root@wiki wiki]# 

SELINUX

如果开启了 SELINUX

则通过类似以下的操作来调整目录的 context

代码语言:javascript
复制
[root@wiki www]# getenforce 
Enforcing
[root@wiki www]# ls -lZ /var/www/
drwxr-xr-x. root   root   system_u:object_r:httpd_sys_script_exec_t:s0 cgi-bin
drwxr-xr-x. root   root   system_u:object_r:httpd_sys_content_t:s0 html
lrwxrwxrwx. root   root   unconfined_u:object_r:httpd_sys_content_t:s0 mediawiki -> mediawiki-1.30.0/
drwxr-xr-x. apache apache unconfined_u:object_r:httpd_sys_content_t:s0 mediawiki-1.30.0
[root@wiki www]# restorecon -FR /var/www/mediawiki-1.30.0/
[root@wiki www]# ls -lZ /var/www/
drwxr-xr-x. root   root   system_u:object_r:httpd_sys_script_exec_t:s0 cgi-bin
drwxr-xr-x. root   root   system_u:object_r:httpd_sys_content_t:s0 html
lrwxrwxrwx. root   root   unconfined_u:object_r:httpd_sys_content_t:s0 mediawiki -> mediawiki-1.30.0/
drwxr-xr-x. apache apache system_u:object_r:httpd_sys_content_t:s0 mediawiki-1.30.0
[root@wiki www]# restorecon -FR /var/www/mediawiki
[root@wiki www]# ls -lZ /var/www/
drwxr-xr-x. root   root   system_u:object_r:httpd_sys_script_exec_t:s0 cgi-bin
drwxr-xr-x. root   root   system_u:object_r:httpd_sys_content_t:s0 html
lrwxrwxrwx. root   root   system_u:object_r:httpd_sys_content_t:s0 mediawiki -> mediawiki-1.30.0/
drwxr-xr-x. apache apache system_u:object_r:httpd_sys_content_t:s0 mediawiki-1.30.0
[root@wiki www]# 

进行访问

浏览器中打开 http://192.168.56.214/mediawiki/

本文系转载,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文系转载前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 前言
  • 操作
    • 依赖
      • 环境
        • 软件环境
          • 依赖包安装
            • 创建数据库和为用户分配权限
              • 下载 wikimedia 软件包
                • 解压 mediawiki 到合适的路径
                  • 确认防火墙开放
                    • 确认 SELINUX 放行
                      • SELINUX
                    • 进行访问
                    相关产品与服务
                    云数据库 MariaDB
                    腾讯云数据库 MariaDB(TencentDB for MariaDB) 让您轻松在云端部署、使用 MariaDB 数据库。MariaDB 是在 MySQL 版权被 Oracle 收购后,由 MySQL 创始人 Monty 创立,其版权授予了“MariaDB基金会(非营利性组织)”以保证 MariaDB 永远开源,良好的开源策略,是企业级应用的最优选择,主流开源社区系统/软件的数据库系统,均已默认配置 MariaDB。
                    领券
                    问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档