From Mageia wiki
Jump to: navigation, search

Contents

Introduction

This document describes steps for moving the content of a wiki from one server to another.
This method has been tested moving a mediawiki (using mysql/mariadb and Apache) between Mageia 5 and Mageia 6 servers (in 2017) and also between Mageia 8 and Mageia 9 servers (in 2025).

Benefits

This method provides a way to take a complete backup of a mediawiki content and restore the wiki content onto a different server.

  1. Simplifies upgrade of server
  2. Provides complete backup which can be stored off line for recovery (eg taking a snapshot)

Overview

  1. On old server: backup wiki content
  2. On new server:
    1. install operating system
    2. copy wiki backup content from old server to new wiki server
    3. recover old server's mediawiki configuration file "LocalSettings.php" (database name, password, etc)
    4. install mysql/mariadb packages
    5. configure mysql/mariadb
    6. install mediawiki and apache packages
    7. configure apache and mediawiki
    8. recover old mediawiki uploaded files/images from tar backups
    9. recover old mediawiki content from backup sql dump
    10. test and verify new server has content from old server

Backup wiki content

Use the "mk_wiki_backup" shell script (see Appendix-1 below) to create the wiki content backup directory.

Modify the script's configuration section "local site definitions" as needed.

Backup wiki content from the old server is written to whatever directory is defined by the ${bkd} variable in script mk_wiki_backup

CAUTION: the wiki's configuration file "etc/mediawiki/LocalSettings.php" which contains security sensitive information such as passwords is written to the ${bkd} directory.
Therefore, take precautions to secure any copies of the wiki content backup.

Example:

chmod 700 ${bkd}

To create the backup, with root access, run "mk_wiki_backup" .

Recovery Steps

Install new system

Things to check after installing Mageia Linux before you start installing mysql/mariadb/mediawiki

Firewall

As part of the initial configuration of your new server, check the firewall configuration by running /usr/bin/drakfirewall. This will, if needed, install the shorewall package.

Your needs may vary but typically you need to enable: Web server, SSH server, email server, echo request (ping).

Install and initially configure mysql/mariadb

Step a: Copy the backup directory from old to new server

Example:

bkd=/home/user/Downloads/mediawiki_backup/
rsync -ave ssh ${bkd} user@${new_server}:${bkd}

Step b: Recover LocalSettings.php from backup

We need some of the configuration data in the old LocalSettings.php file for initial configuration of the new wiki. So, we will extract it from the tar archive created by "mk_wiki_backup".

Example:

cd ${bkd}/..
mkdir mediawiki_backup_extracted
chmod 700 mediawiki_backup_extracted  # protect content
cd mediawiki_backup_extracted
tar zxvf ../mediawiki_backup/etc_mediawiki.tgz

less etc/mediawiki/LocalSettings.php        # view content of extracted old LocalSettings.php

This should create mediawiki_backup_extracted/etc/mediawiki/ where a copy of the old LocalSettings.php will be found.

Step c: Install mysql mariadb packages

Installing mySQL/MariaDB for a mediawiki on Mageia 6 linux:

urpmi mariadb mariadb-common mysql-MariaDB

Example:

[root@test-wiki ~]# urpmi mariadb mariadb-common mysql-MariaDB
To satisfy dependencies, the following packages are going to be installed:
  Package                        Version      Release       Arch    
(medium "Core Release")
  lib64aio1                      0.3.110      4.mga6        x86_64  
  mariadb                        10.1.23      1.mga6        x86_64  
  mariadb-client                 10.1.23      1.mga6        x86_64  
  mariadb-common                 10.1.23      1.mga6        x86_64  
  mariadb-common-core            10.1.23      1.mga6        x86_64  
  mariadb-core                   10.1.23      1.mga6        x86_64  
  mariadb-extra                  10.1.23      1.mga6        x86_64  (recommended)
  mariadb-feedback               10.1.23      1.mga6        x86_64  (recommended)
  mysql-MariaDB                  10.1.23      1.mga6        x86_64  
143MB of additional disk space will be used.
12MB of packages will be retrieved.
Proceed with the installation of the 9 packages? (Y/n) y


    distrib-coffee.ipsl.jussieu.fr::mageia/distrib/6/x86_64/media/core/release/mariadb-10.1.23-1.mga6.x86_64.rpm
    distrib-coffee.ipsl.jussieu.fr::mageia/distrib/6/x86_64/media/core/release/mysql-MariaDB-10.1.23-1.mga6.x86_64.rpm                                                                                                                      
    distrib-coffee.ipsl.jussieu.fr::mageia/distrib/6/x86_64/media/core/release/mariadb-feedback-10.1.23-1.mga6.x86_64.rpm                                                                                                                   
    distrib-coffee.ipsl.jussieu.fr::mageia/distrib/6/x86_64/media/core/release/lib64aio1-0.3.110-4.mga6.x86_64.rpm                                                                                                                          
    distrib-coffee.ipsl.jussieu.fr::mageia/distrib/6/x86_64/media/core/release/mariadb-client-10.1.23-1.mga6.x86_64.rpm                                                                                                                     
    distrib-coffee.ipsl.jussieu.fr::mageia/distrib/6/x86_64/media/core/release/mariadb-extra-10.1.23-1.mga6.x86_64.rpm                                                                                                                      
    distrib-coffee.ipsl.jussieu.fr::mageia/distrib/6/x86_64/media/core/release/mariadb-core-10.1.23-1.mga6.x86_64.rpm                                                                                                                       
    distrib-coffee.ipsl.jussieu.fr::mageia/distrib/6/x86_64/media/core/release/mariadb-common-core-10.1.23-1.mga6.x86_64.rpm                                                                                                                
    distrib-coffee.ipsl.jussieu.fr::mageia/distrib/6/x86_64/media/core/release/mariadb-common-10.1.23-1.mga6.x86_64.rpm                                                                                                                     
installing mariadb-feedback-10.1.23-1.mga6.x86_64.rpm mysql-MariaDB-10.1.23-1.mga6.x86_64.rpm mariadb-10.1.23-1.mga6.x86_64.rpm mariadb-core-10.1.23-1.mga6.x86_64.rpm mariadb-common-10.1.23-1.mga6.x86_64.rpm mariadb-common-core-10.1.23-1.mga6.x86_64.rpm lib64aio1-0.3.110-4.mga6.x86_64.rpm mariadb-client-10.1.23-1.mga6.x86_64.rpm mariadb-extra-10.1.23-1.mga6.x86_64.rpm from /var/cache/urpmi/rpms
Preparing...                     ##########################################################################################################################################################################################################
      1/9: lib64aio1             ##########################################################################################################################################################################################################
      2/9: mariadb-client        ##########################################################################################################################################################################################################
      3/9: mariadb-common        ##########################################################################################################################################################################################################
      4/9: mariadb-common-core   ##########################################################################################################################################################################################################
      5/9: mariadb-core          ##########################################################################################################################################################################################################
      6/9: mariadb               ##########################################################################################################################################################################################################
      7/9: mysql-MariaDB         ##########################################################################################################################################################################################################
      8/9: mariadb-feedback      ##########################################################################################################################################################################################################
      9/9: mariadb-extra         ##########################################################################################################################################################################################################
----------------------------------------------------------------------
More information on package mariadb-10.1.23-1.mga6.x86_64

NOTE: MariaDB is installed without root password, it is recommended to set the
root password with the following command as soon as possible:

   mysqladmin password

The initscript used to start mysql has been reverted to use the one shipped
by MariaDB. This means the following changes:

 * The generation of the initial system mysql database is now done when mysql
   is started from the initscript and only if the /var/lib/mysql/mysql
   directory is empty (mysql_install_db). Previousely this was quite hidden and
   silently done at (rpm) install time. As a consequence to this change you may
   have to perform some manual tasks to upgrade the mysql system database and
   such. So, doing something like this might help you:

   systemctl stop mysqld.service
   TMPDIR=/var/tmp mysql_install_db
   mysql_upgrade --skip-write-binlog

The cluster functionalities (ndb) has been deactivated and will be removed in
future mysql versions. Oracle has a new product named mysql-cluster that
replaces the cluster functionalities.

The mysql-common-core package ships with a default /etc/my.cnf file that is 
based on the my-medium.cnf file that comes with the source code.

----------------------------------------------------------------------

Step d: Check if database service is running

mysqladmin status

This example shows the database service is not running:

[root@test-wiki ~]# mysqladmin status
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2 "No such file or directory")'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!

Step e: If database service is not running then start it

systemctl start mysqld && systemctl status mysqld

Example:

[root@test-wiki ~]# systemctl start mysqld && systemctl status mysqld
● mysqld.service - MySQL database server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2017-07-03 15:25:39 BST; 38ms ago
  Process: 58396 ExecStartPre=/usr/sbin/mysqld-prepare-db-dir (code=exited, status=0/SUCCESS)
 Main PID: 58548 (mysqld)
   Status: "Taking your SQL requests now..."
   CGroup: /system.slice/mysqld.service
           └─58548 /usr/sbin/mysqld

Jul 03 15:25:39 test-wiki.home mysqld[58548]: 2017-07-03 15:25:39 140680201766976 [Note] InnoDB: Waiting for purge to start
Jul 03 15:25:39 test-wiki.home mysqld[58548]: 2017-07-03 15:25:39 140680201766976 [Note] InnoDB:  Percona XtraDB (http://www.percona.com) 5.6.35-80.0 started; log sequence number 1616819
Jul 03 15:25:39 test-wiki.home mysqld[58548]: 2017-07-03 15:25:39 140679560791808 [Note] InnoDB: Dumping buffer pool(s) not yet started
Jul 03 15:25:39 test-wiki.home mysqld[58548]: 2017-07-03 15:25:39 140680201766976 [Warning] mysqld: GSSAPI plugin : default principal 'mariadb/test-wiki.home@' not found in keytab
Jul 03 15:25:39 test-wiki.home mysqld[58548]: 2017-07-03 15:25:39 140680201766976 [ERROR] mysqld: Server GSSAPI error (major 851968, minor 2529639093) : gss_acquire_cred failed -Unspecified GSS failure.  Minor code may provide more infor
Jul 03 15:25:39 test-wiki.home mysqld[58548]: 2017-07-03 15:25:39 140680201766976 [ERROR] Plugin 'gssapi' init function returned error.
Jul 03 15:25:39 test-wiki.home mysqld[58548]: 170703 15:25:39 server_audit: MariaDB Audit Plugin version 1.4.1 STARTED.
Jul 03 15:25:39 test-wiki.home mysqld[58548]: 170703 15:25:39 server_audit: Query cache is enabled with the TABLE events. Some table reads can be veiled.2017-07-03 15:25:39 140680201766976 [Note] /usr/sbin/mysqld: ready for connections.
Jul 03 15:25:39 test-wiki.home mysqld[58548]: Version: '10.1.23-MariaDB'  socket: '/var/lib/mysql/mysql.sock'  port: 0  Mageia MariaDB Server
Jul 03 15:25:39 test-wiki.home systemd[1]: Started MySQL database server.


Note: in this example, we see a warning message:

[Warning] mysqld: GSSAPI plugin : default principal 'mariadb/test-wiki.home@' not found in keytab

This is because by default the GSSAPI plugin for use with kerberos authentication is loaded. If you are not using kerberos and wish to disable the plugin then you simply edit the file /etc/my.cnf.d/auth_gssapi.cnf and comment out the line with "plugin-load-add" by inserting a "#".

Example:

[mpb@test-wiki Downloads]$ ls -l /etc/my.cnf.d/auth_gssapi.cnf
-rw-r--r-- 1 root root 42 Jul  6 18:33 /etc/my.cnf.d/auth_gssapi.cnf

[mpb@test-wiki Downloads]$ cat /etc/my.cnf.d/auth_gssapi.cnf
[mariadb]
#plugin-load-add=auth_gssapi.so

Then restart the mysqld service to confirm that the GSSAPI plugin is not loaded:

[root@test-wiki /]# systemctl restart mysqld && systemctl status mysqld
● mysqld.service - MySQL database server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2017-07-06 18:59:59 BST; 23h ago
  Process: 5895 ExecStartPre=/usr/sbin/mysqld-prepare-db-dir (code=exited, status=0/SUCCESS)
 Main PID: 5911 (mysqld)
   Status: "Taking your SQL requests now..."
   CGroup: /system.slice/mysqld.service
           └─5911 /usr/sbin/mysqld

Jul 06 18:59:59 test-wiki.home mysqld[5911]: 2017-07-06 18:59:59 140180693276736 [Note] InnoDB: 128 rollback segment(s) are active.
Jul 06 18:59:59 test-wiki.home mysqld[5911]: 2017-07-06 18:59:59 140180693276736 [Note] InnoDB: Waiting for purge to start
Jul 06 18:59:59 test-wiki.home mysqld[5911]: 2017-07-06 18:59:59 140180693276736 [Note] InnoDB:  Percona XtraDB (http://www.percona.com) 5.6.35-80.0 started; log sequence number 21941776
Jul 06 18:59:59 test-wiki.home mysqld[5911]: 2017-07-06 18:59:59 140180069517056 [Note] InnoDB: Dumping buffer pool(s) not yet started
Jul 06 18:59:59 test-wiki.home mysqld[5911]: 170706 18:59:59 server_audit: MariaDB Audit Plugin version 1.4.1 STARTED.
Jul 06 18:59:59 test-wiki.home mysqld[5911]: 170706 18:59:59 server_audit: Query cache is enabled with the TABLE events. Some table reads can be veiled.2017-07-06 18:59:59 140180693276736 [Note] /usr/sbin/mysqld: ready for connections.
Jul 06 18:59:59 test-wiki.home mysqld[5911]: Version: '10.1.23-MariaDB'  socket: '/var/lib/mysql/mysql.sock'  port: 0  Mageia MariaDB Server
Jul 06 18:59:59 test-wiki.home systemd[1]: Started MySQL database server.
Jul 06 19:04:59 test-wiki.home mysqld[5911]: 2017-07-06 19:04:59 140180035946240 [Note] feedback plugin: report to 'https://mariadb.org/feedback_plugin/post' was sent
Jul 06 19:05:00 test-wiki.home mysqld[5911]: 2017-07-06 19:05:00 140180035946240 [Note] feedback plugin: server replied 'ok'

Confirm database service is running:

mysqladmin status

Example:

[root@test-wiki ~]# mysqladmin status
Uptime: 78  Threads: 1  Questions: 1  Slow queries: 0  Opens: 17  Flush tables: 1  Open tables: 11  Queries per second avg: 0.012

Step f: Set your own password for the mysql root account

As of 2017_07_05, the mediawiki installation guide for Linux (ref: https://www.mediawiki.org/wiki/Manual:Installing_MediaWiki#Unix.2FLinux_installation ) specifically suggests in Step3 to use the following to set the mysql root account password

3. Set a password for the "root" account on your database server. mysqladmin -u root password yourpassword

This does not work for me in Mageia 6. I found another method as follows:

# Verify the mysql root account password is not set

if mysql -uroot -e 'SELECT 1;' > /dev/null 2>&1 ; then
    echo -e "You do not appear to have a mysql root password set.\n"
else
    echo -e "mysql root account password has been set"
fi
# Set the mysql root account password

export passwd="YOUR_OWN_MYSQL_ROOT_PASSWORD"
mysql -uroot mysql -se "UPDATE user SET password=PASSWORD('$passwd') WHERE User='root';"

# Restart mysql service
systemctl restart mysqld.service && systemctl status mysqld.service
# Verify the mysql root account password is now set

if mysql -uroot -e 'SELECT 1;' > /dev/null 2>&1 ; then
    echo -e "You do not appear to have a mysql root password set.\n"
else
    echo -e "mysql root account password has been set"
fi

Example:


[root@test-wiki ~]# if mysql -uroot -e 'SELECT 1;' > /dev/null 2>&1 ; then
>     echo -e "You do not appear to have a mysql root password set.\n"
> else
>     echo -e "mysql root account password has been set"
> fi
You do not appear to have a mysql root password set.

[root@test-wiki ~]# passwd="PUT_YOUR_OWN_MYSQL_ROOT_PASSWORD_HERE"
[root@test-wiki ~]# export passwd
[root@test-wiki ~]# mysql -uroot mysql -se "UPDATE user SET password=PASSWORD('$passwd') WHERE User='root';"

[root@test-wiki /]# systemctl start mysqld && systemctl status mysqld
● mysqld.service - MySQL database server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2017-07-06 18:59:59 BST; 23h ago
  Process: 5895 ExecStartPre=/usr/sbin/mysqld-prepare-db-dir (code=exited, status=0/SUCCESS)
 Main PID: 5911 (mysqld)
   Status: "Taking your SQL requests now..."
   CGroup: /system.slice/mysqld.service
           └─5911 /usr/sbin/mysqld

Jul 06 18:59:59 test-wiki.home mysqld[5911]: 2017-07-06 18:59:59 140180693276736 [Note] InnoDB: 128 rollback segment(s) are active.
Jul 06 18:59:59 test-wiki.home mysqld[5911]: 2017-07-06 18:59:59 140180693276736 [Note] InnoDB: Waiting for purge to start
Jul 06 18:59:59 test-wiki.home mysqld[5911]: 2017-07-06 18:59:59 140180693276736 [Note] InnoDB:  Percona XtraDB (http://www.percona.com) 5.6.35-80.0 started; log sequence number 21941776
Jul 06 18:59:59 test-wiki.home mysqld[5911]: 2017-07-06 18:59:59 140180069517056 [Note] InnoDB: Dumping buffer pool(s) not yet started
Jul 06 18:59:59 test-wiki.home mysqld[5911]: 170706 18:59:59 server_audit: MariaDB Audit Plugin version 1.4.1 STARTED.
Jul 06 18:59:59 test-wiki.home mysqld[5911]: 170706 18:59:59 server_audit: Query cache is enabled with the TABLE events. Some table reads can be veiled.2017-07-06 18:59:59 140180693276736 [Note] /usr/sbin/mysqld: ready for connections.
Jul 06 18:59:59 test-wiki.home mysqld[5911]: Version: '10.1.23-MariaDB'  socket: '/var/lib/mysql/mysql.sock'  port: 0  Mageia MariaDB Server
Jul 06 18:59:59 test-wiki.home systemd[1]: Started MySQL database server.
Jul 06 19:04:59 test-wiki.home mysqld[5911]: 2017-07-06 19:04:59 140180035946240 [Note] feedback plugin: report to 'https://mariadb.org/feedback_plugin/post' was sent
Jul 06 19:05:00 test-wiki.home mysqld[5911]: 2017-07-06 19:05:00 140180035946240 [Note] feedback plugin: server replied 'ok'


[root@test-wiki ~]# if mysql -uroot -e 'SELECT 1;' > /dev/null 2>&1 ; then
>     echo -e "You do not appear to have a mysql root password set.\n"
> else
>     echo -e "mysql root account password has been set"
> fi
mysql root account password has been set

Step g: Identify mediawiki database name, user, password from old /etc/mediawiki/LocalSettings.php configuration file

Extract the old /etc/mediawiki/LocalSettings.php configuration file from your backup (tar archive) and make a note of:

  1. $wgDBname
  2. $wgDBuser
  3. $wgDBpassword

Example:

[mpb@test-wiki Downloads]$ grep -iE "wgDBname|wgDBuser|wgDBpassword" mediawiki_backup_extracted/etc/mediawiki/LocalSettings.php
$wgDBname = "my_wiki";
$wgDBuser = "root";
$wgDBpassword = "PUT_YOUR_OWN_MYSQL_ROOT_PASSWORD_HERE";

Step h: Create initial database and give permission to access

Connect to the mysql service in order to create a new (empty) database and set permission for your defined user to access it.

# connect to mysql service

mysql -u root -p
password:

Example:

[mpb@test-wiki ~]$ mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 6
Server version: 10.1.23-MariaDB Mageia 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)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.05 sec)

Create an initial empty database for your mediawiki using the wgDBname name from the old /etc/mediawiki/LocalSettings.php (see Step 5 (above)).

CREATE DATABASE my_wiki;

Example:

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

MariaDB [(none)]> show databases;

+--------------------+
| Database           |
+--------------------+
| information_schema |
| my_wiki            |
| mysql              |
| performance_schema |
| test               |
+--------------------+
5 rows in set (0.00 sec)

Enable permissions for the mediawiki user defined using the wgDBname, wgDBuser, "localhost", and wgDBpassword names from the old /etc/mediawiki/LocalSettings.php (see Step 5 (above)).
NB: be sure to use "localhost" for the server at this point.

GRANT ALL PRIVILEGES ON my_wiki.* TO 'root'@'localhost' IDENTIFIED BY 'PUT_YOUR_OWN_MYSQL_ROOT_PASSWORD_HERE';

Example:

MariaDB [(none)]> GRANT ALL PRIVILEGES ON my_wiki.* TO 'root'@'localhost' IDENTIFIED BY 'PUT_YOUR_OWN_MYSQL_ROOT_PASSWORD_HERE';
Query OK, 0 rows affected (0.05 sec)

NB Skip the following if your mysql/mariadb server is running on the same machine as your mediawiki.

# "If your database is not running on the same server as your web server, you need to give the appropriate web server hostname."
# ref: https://www.mediawiki.org/wiki/Manual:Installing_MediaWiki#Unix.2FLinux_installation
#

MariaDB [(none)]> GRANT ALL PRIVILEGES ON my_wiki.* TO 'root'@'test-wiki.home' IDENTIFIED BY 'PUT_YOUR_OWN_MYSQL_ROOT_PASSWORD_HERE';
Query OK, 0 rows affected (0.01 sec)

Install and initially configure Apache and mediawiki

Step i: Install packages needed for mediawiki

urpmi apache apache-mod_php apache-mod_ssl mediawiki mediawiki-mysql postfix imagemagick php-mysqli git

Step j: Ensure you have correct "ServerName" defined for Apache

The Apache configuration file /etc/httpd/conf/httpd.conf needs the fully qualified domain name of your server defined for the ServerName parameter.

Example:

[mpb@test-wiki ~]$ grep -iE ServerName /etc/httpd/conf/httpd.conf
# ServerName gives the name and port that the server uses to identify itself.
#ServerName www.example.com:80
ServerName test-wiki.home:80

If you change /etc/httpd/conf/httpd.conf you can restart Apache:

Example:

[root@test-wiki /]# systemctl restart httpd && systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2017-07-07 18:19:18 BST; 7ms ago
 Main PID: 66286 (httpd)
   Status: "Processing requests..."
   CGroup: /system.slice/httpd.service
           ├─66286 /usr/sbin/httpd -DFOREGROUND
           ├─66289 /usr/sbin/httpd -DFOREGROUND
           └─66290 /usr/sbin/httpd -DFOREGROUND

Jul 07 18:19:18 test-wiki.home systemd[1]: Starting The Apache HTTP Server...
Jul 07 18:19:18 test-wiki.home systemd[1]: Started The Apache HTTP Server.

Step k: Check Apache is running, if needed, start it

[root@test-wiki /]# systemctl status httpd.service
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2017-07-07 18:43:03 BST; 3 days ago
 Main PID: 67162 (httpd)
   Status: "Total requests: 42; Idle/Busy workers 100/0;Requests/sec: 0.00013; Bytes served/sec:  85 B/sec"
   CGroup: /system.slice/httpd.service
           ├─ 67162 /usr/sbin/httpd -DFOREGROUND
           ├─ 67165 /usr/sbin/httpd -DFOREGROUND
           ├─ 67166 /usr/sbin/httpd -DFOREGROUND
           ├─ 67167 /usr/sbin/httpd -DFOREGROUND
           ├─ 67168 /usr/sbin/httpd -DFOREGROUND
           ├─ 67169 /usr/sbin/httpd -DFOREGROUND
           ├─ 67182 /usr/sbin/httpd -DFOREGROUND
           ├─ 67188 /usr/sbin/httpd -DFOREGROUND
           ├─ 67191 /usr/sbin/httpd -DFOREGROUND
           ├─ 67192 /usr/sbin/httpd -DFOREGROUND
           └─112899 /usr/sbin/httpd -DFOREGROUND

Jul 07 18:43:03 test-wiki.home systemd[1]: Starting The Apache HTTP Server...
Jul 07 18:43:03 test-wiki.home systemd[1]: Started The Apache HTTP Server.

If the httpd.service (Apache) is not running then it can be started with:

systemctl start httpd.service && systemctl status httpd.service


Step l: Connect using browser to http://127.0.0.1/mediawiki/mw-config to complete initial mediawiki configuration

Verify your web browser connection is *not* via proxy.

In some organizations, it is normal to configure your web browser (Firefox, Google Chrome, etc) to use a proxy server. For the purposes of installing and configuring mediawiki, we need a direct web browser connection to our 127.0.0.1 locally. Check and verify your web browser preferences are set for "direct" connection and not using a web proxy.

You can change this back to using proxy after installing and configuring mediawiki.

Connect to: http://127.0.0.1/mediawiki/mw-config

First select the language you wish to use.

Next, the environment is checked to make sure you have everything needed for mediawiki. For example, it is useful to have the "ImageMagick" package installed. At this point, you can pause the initial configuration of the mediawiki and install any needed packages and restart the mediawiki configuration.

If the basic minimum requirements are met, you should see the message:

The environment has been checked. You can install MediaWiki.

Example screenshot (for Mageia 7):

2020 01 12 MediaWiki 1.31.6 installation on Mageia7 with Firefox screenshot b.png

At the end of this configuration, you have the opportunity to download a new LocalSettings.php configuration file in your ${HOME}/Downloads/ directory. Download this and keep a copy for reference.

NB LocalSettings.php contains security information in the form of plain text password. So, it is important to restrict access to this file:

chmod 600 LocalSettings.php  # protect contents of LocalSettings.php for security reasons


Copy this new LocalSettings.php configuration file to /etc/mediawiki/LocalSettings.php. Check the ownership is "apache" and permissions are 600:

[root@test-wiki mediawiki]# ls -l /etc/mediawiki/LocalSettings.php
-rw------- 1 apache root 4323 Jul  6 15:16 /etc/mediawiki/LocalSettings.php

To recover the mediawiki content from the old wiki server, we need to use the key settings from the old LocalSettings.php file (from the backup). So, manually compare the old (backed up) copy of LocalSettings.php and the newly generated one.

Pay particular attention to the following settings:

  1. $wgServer = "http://YOUR.SERVER.FQDN"; (Note: if you use the form: "//YOUR_SERVER.FQDN" it works for both http and https)
  2. $wgStylePath = "$wgScriptPath/skins";
  3. $wgLogo = "$wgStylePath/common/images/OUR_logo_150x150_transparent.png";
  4. $wgEmergencyContact = "YOUR.EMAIL@YOUR_EMAIL_PROVIDER.com";
  5. $wgPasswordSender = "apache@YOUR.SERVER.FQDN";
  6. $wgEnotifUserTalk = true; # UPO
  7. $wgEnotifWatchlist = true; # UPO


Also, take care about any references to "extensions" in the old wiki server configuration. These need to appear in the new wiki server's /etc/mediawiki/LocalSettings.php. Mediawiki "extensions" can be identified via the browser http://127.0.0.1/mediawiki/mw-config configuration but they can also be manually added to the new LocalSettings.php.

Recover mediawiki content from backup of old server

Step m: Recover tar archives of uploaded files/images from old server

Recover the tar archives of image and upload files from the old wiki. These tar archives were created by the "mk_wiki_backup" script into the backup directory. Example:

bkd=/home/user/Downloads/mediawiki_backup
cd /
tar zxvf ${bkd}/usr_share_mediawiki_skins_common_images.tgz
tar zxvf ${bkd}/var_www_mediawiki_images.tgz

Step n: Recover mediawiki SQL dump from old server

Recover wiki database content from SQL dump (created by the "mk_wiki_backup" script).

gunzip -c ${bkd}/my_wiki.sql.gz | /bin/sudo mysql -C -p my_wiki     # import page data from wiki backup

Step o: Verify new LocalSettings.php

Check the new /etc/mediawiki/LocalSettings.php file comparing it with the same file recovered from the old server. Confirm configuration data is good for new server (eg hostname.domain_name is correct).

During testing of this process, I found one time I had forgotten to enable "extensions" in the new mediawiki. The effect of this was that image files were not being displayed on the new server.

For the move between Mageia 5 and 6 in 2017 I manually added the following snippet to the new server's /etc/mediawiki/LocalSettings.php and then the wiki content was presented correctly.

# START-OF-snippet from /etc/mediawiki/LocalSettings.php follows:

# End of automatically generated settings.
# Add more configuration options below.

### # Enabled Extensions. Most extensions are enabled by including the base extension file here
### # but check specific extension documentation for more details
### # The following extensions were automatically enabled:
require_once "$IP/extensions/Cite/Cite.php";
require_once "$IP/extensions/ConfirmEdit/ConfirmEdit.php";
require_once "$IP/extensions/Gadgets/Gadgets.php";
require_once "$IP/extensions/ImageMap/ImageMap.php";
require_once "$IP/extensions/InputBox/InputBox.php";
require_once "$IP/extensions/LocalisationUpdate/LocalisationUpdate.php";
require_once "$IP/extensions/Nuke/Nuke.php";
require_once "$IP/extensions/ParserFunctions/ParserFunctions.php";
require_once "$IP/extensions/PdfHandler/PdfHandler.php";
require_once "$IP/extensions/Poem/Poem.php";
require_once "$IP/extensions/Renameuser/Renameuser.php";
require_once "$IP/extensions/SpamBlacklist/SpamBlacklist.php";
require_once "$IP/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php";
require_once "$IP/extensions/TitleBlacklist/TitleBlacklist.php";
require_once "$IP/extensions/WikiEditor/WikiEditor.php";


# End of automatically generated settings.
# Add more configuration options below.

$wgFileExtensions = array( 'png', 'gif', 'jpg', 'jpeg', 'doc',
        'xls', 'mpp', 'pdf', 'ppt', 'tiff', 'bmp', 'docx', 'xlsx',
        'pptx', 'ps', 'odt', 'ods', 'odp', 'odg', 'zip', 'txt',
        'mp3', 'mp4', 'wmv'
        );

# END-OF-snippet from /etc/mediawiki/LocalSettings.php 

For the move between Mageia 8 and 9 in 2025 I manually added the following snippet to the new server's /etc/mediawiki/LocalSettings.php and then the wiki content was presented correctly.

# START-OF-snippet from /etc/mediawiki/LocalSettings.php follows:

# End of automatically generated settings.
# Add more configuration options below.

##LOCAL - manually added extensions

wfLoadExtension( 'Cite' );
wfLoadExtension( 'Gadgets' );
wfLoadExtension( 'ImageMap' );
wfLoadExtension( 'InputBox' );
wfLoadExtension( 'LocalisationUpdate' );
wfLoadExtension( 'Nuke' );
wfLoadExtension( 'ParserFunctions' );
wfLoadExtension( 'Poem' );
wfLoadExtension( 'Renameuser' );
wfLoadExtension( 'SpamBlacklist' );
wfLoadExtension( 'SyntaxHighlight_GeSHi' );
wfLoadExtension( 'TitleBlacklist' );
wfLoadExtension( 'WikiEditor' );

# Add more configuration options below.

$wgFileExtensions = array( 'png', 'gif', 'jpg', 'jpeg', 'doc',
        'xls', 'mpp', 'pdf', 'ppt', 'tiff', 'bmp', 'docx', 'xlsx',
        'pptx', 'ps', 'odt', 'ods', 'odp', 'odg', 'zip', 'txt',
        'mp3', 'mp4', 'wmv'
        );

# END-OF-snippet from /etc/mediawiki/LocalSettings.php

Step p: Test email from and to mediawiki server

Mediawiki makes use of email to notify users and to allow users to reset their forgotten password. For this to work, it is important to verify email send from and delivered to the mediawiki server works OK.

Example:

echo "this is a test" | mail -v -s "Testing email from mediawiki server" my-email.address

If your mediawiki server is located in an intranet, you may need to configure the mail server to use a email relay host for mail delivery. First identify your organization's email relay host.

Next configure your mediawiki mail server to deliver email via the relay host.

Example:

# Our organization's email relay is: "smtp-relay.my.organization"
# Update /etc/postfix/main.cf with a "relayhost"

f=/etc/postfix/main.cf
echo "# added on $(date) by YOUR-USER-NAME" >> ${f}
echo "relayhost = [smtp-relay.my.organization]:25" >> ${f}

Verify that email is correctly delivered via the relayhost.

For inbound email to the mediawiki server, we need to configure the Mageia firewall to allow email delivery.

# run the firewall configuration tool to enable inbound delivery of email

/usr/bin/drakfirewall

Step q: Test new mediawiki server

Test new server wiki access: confirm can see all the old wiki content pages as before.


Trouble shooting

Using this method for moving a wiki from Mageia 5 to Mageia7 an issue was encountered so that only a blank page was shown when connecting to the new version of the wiki.

Examining the httpd logs in /var/log/httpd revealed warnings like:

[Sun Jan 12 17:03:59.537416 2020] [php:warn] [pid 77900] [client 192.168.101.17:56514] PHP Warning:  require_once(/usr/share/mediawiki/extensions/ConfirmEdit/ConfirmEdit.php): failed to open stream: No such file or directory in /etc/mediawiki/LocalSettings.php on line 164

Checking the /etc/mediawiki/LocalSettings.php file it was found that some of the manually added additions of extensions were duplicates of extensions that the via-web-interface configuration had defined. Specifically:

ConfirmEdit.php
PdfHandler.php
SpamBlacklist.php
TitleBlacklist.php
WikiEditor.php

So, commented these out (putting a "#" in column 1) for these in manually added extensions section. This resolved the warning messages issue in /var/log/httpd/error_log when httpd and mysqld were restarted.

systemctl restart mysqld.service && systemctl status mysqld.service
systemctl restart httpd.service && systemctl status httpd.service

This seemed to work and some mediawiki pages were presented but after logging in (to the wiki) the following was presented:

"Fatal exception of type "Wikimedia\Rdbms\DBQueryError"
2020 01 12 MediaWiki 1.31.6 installation on Mageia7 with Firefox screenshot c.png

Some research revealed the fix at this page: https://www.mediawiki.org/wiki/Topic:U26n1a1pgo0078tt

The solution was to return to the web configuration: http://127.0.0.1/mediawiki/mw-config so that update.php gets run. See comment by bawolff on link above:

"Update.php (or the web updater by going to mywiki.com/w/mw-config ) will add the table for you, so there is no need to add it manually."

After completing this normal access to the moved wiki worked OK.

Appendix-1: mk_wiki_backup script

#!/bin/sh

# Name          mk_wiki_backup
# Purpose       Backup wiki content: pages, image files (uploaded), configuration (/etc/mediawiki/)
# Author        Paul Blackburn
# Version       0.2
# Updated       Mon 15 Feb 16:58:07 GMT 2016 
#
# Usage
#               This script needs to be run as root for privileged access to data.
#               This script may be modified as needed for your wiki.
#               Essential data is extracted to gzipped tar files which can be copied to off-site for backup
#               or used to migrate data to a new (eg updated) server instance.
# Caution
#               Backup wiki content contains security sensitive data. Protect by restricting access.
#
# Reference:
#               https://sharkysoft.com/wiki/how_to_move_a_MediaWiki_wiki_from_one_server_to_another
#               https://www.mediawiki.org/wiki/Manual:Moving_a_wiki
#               https://lists.wikimedia.org/pipermail/mediawiki-l/2008-August/028294.html
 

# define site variables

# Local backup directory for tar gzipped data files
bkd=/home/mpb/Downloads/mediawiki_backup
echo "Backup directory is: ${bkd}/"

if [ ! -d ${bkd} ]; then
                mkdir -p ${bkd} && chmod 700 ${bkd} && echo created ${bkd}
fi

# variables from /etc/mediawiki/LocalSettings.php

wiki_conf=/etc/mediawiki/LocalSettings.php

if [ -s ${wiki_conf} ]; then
        echo "Wiki configuration file is ${wiki_conf}"
else
        echo "Error: missing wiki configuration file ${wiki_conf}" >&2
        exit 1
fi

# find wiki database name from wiki config
wgDBname=$(grep "^.wgDBname" ${wiki_conf} | grep -v "^#" | sed -e "s/^.//" | cut -d\" -f2)

# find wiki user name from wiki config
wgDBuser=$(grep wgDBuser ${wiki_conf} | grep -v "^#" | sed -e "s/^.//" | cut -d\" -f2)

# find wiki user password from wiki config
wgDBpassword=$(grep wgDBpassword ${wiki_conf} | grep -v "^#" | sed -e "s/^.//" | cut -d\" -f2)

# Dump wiki's SQL database (all pages)
mysqldump -u ${wgDBuser} ${wgDBname} -p${wgDBpassword} -c | gzip > ${bkd}/${wgDBname}.sql.gz


# Backup wiki configuration
cd / && tar czf ${bkd}/etc_mediawiki.tgz etc/mediawiki/

# Backup images (uploaded files)
cd / && tar czf ${bkd}/var_www_mediawiki_images.tgz var/www/mediawiki/images/

# Backup favicon.ico, OUR_logo NB: this will vary from site to site. Modify for your logo and favicon.ico file
d=usr/share/mediawiki/skins/common/images
f=usr_share_mediawiki_skins_common_images.tgz
cd / && tar czf ${bkd}/${f} ${d}/OUR_logo_150x150_transparent.png ${d}/favicon.ico ${d}/OUR_greenbox_logo_16x16_transparent.ico 

## # Optional other backup
## # Backup extensions (may not be needed: should have updated extensions in new mediawiki already)
## cd / && tar czf ${bkd}/usr_share_mediawiki_extensions.tgz usr/share/mediawiki/extensions/



echo completed

ls -l ${bkd}/

Appendix-2: references

  1. https://wiki.mageia.org/en/Notes_on_moving_a_mediawiki
  2. https://www.mediawiki.org/wiki/Manual:Installing_MediaWiki#Unix.2FLinux_installation
  3. https://sharkysoft.com/wiki/how_to_move_a_MediaWiki_wiki_from_one_server_to_another
  4. https://www.mediawiki.org/wiki/Manual:Moving_a_wiki
  5. https://lists.wikimedia.org/pipermail/mediawiki-l/2008-August/028294.html