MediaWiki

From NST Wiki
Jump to: navigation, search

This page contains some notes related to using a NST system as a MediaWiki server.

Adding MediaWiki (as of NST 28 - 2018-09-17)

Set Up Database Server

MediaWiki requires access to a database. You can use either a MariaDB or PostgreSQL database server. Both are pre-installed on a NST system.

Set Up MariaDB

The easy way to set up the MariaDB server is to:

  • From the NST WUI menu bar, select: Database|MariaDB (MySQL)|MariaDB (MySQL) Database Management.
  • Scroll down to the Setup MariaDB (MySQL) Server section on the page.
  • Find the Change Administrator Password row in the configuration table and set the master password you want to use administering the MySQL server. If you forget to do this, a random password will be used. Should you need to find this password, look for NSTCTMYSQLPASSWD in the file: /etc/nst.conf.
  • If you know what you are doing, feel free to review/tweak other options in the configuration table. If you don't know what you are doing, leave them at their default settings.
  • Press the Setup/Start MariaDB (MySQL) Server button below the table to configure and start the server.

You should see a new page load. The page will take a bit to complete and show the results of setting up and starting the mariadb.service. Once the page finishes loading, press the Return button to return back to the MariaDB (MySQL) Database Service Management page.

At this point, you should see that that the mariadb service is running. Within the table that shows the mariadb service. Find the Boot State column and click on the Enable button corresponding to the mariadb service. This will enable the service at boot time.

This completes the set up of the SQL server. At this point your system should be ready to install MediaWiki.

Set Up sendmail

If you plan on using e-mail with your wiki, you should make sure the sendmail service is setup and configured on your NST system.

From the NST WUI menu bar, select: Network|eMail|Sendmail Service Manager. This page should guide you through the steps of configuring and testing the sendmail service.

NOTE: Depending on your Internet Service Provider, it may be very difficult to get the sendmail service configured and working.

Install MediaWiki Package(s)

To add MediaWiki to a NST system, log in as root and run the following command:

dnf install mediawiki

This will install the basic packages required for MediaWiki support. The other packages (database and web server support packages) should already be installed on your system.

Set up MediaWiki

After installation completes, you will need to set up and configure your wiki.

Edit the file: /etc/httpd/conf.d/mediawiki.conf and uncomment the two lines:

Alias /wiki/skins /usr/share/mediawiki/skins
Alias /wiki /var/www/wiki

Reload the web server configuration file:

systemctl restart httpd.service # For older systems use: service httpd reload

At this point, you can test your configuration by pointing your web browser at: "https://IP_ADDRESS/wiki" (put in your own IP ADDRESS). You should be greeted by a MediaWiki page telling you that you need to set up the wiki.

To complete the MediaWiki setup, simply click on the: "set up the wiki" link and follow the instructions.

Once you complete the MediaWiki setup, it will give you a LocalSettings.php file that needs to be installed. The LocalSettings.php file will likely be in your Downloads folder and can be installed using the following command:

sudo mv ~/Downloads/LocalSettings.php /var/www/wiki/

At this point you should have MediaWiki up and running on your NST system. Directing your browser to https://IP_ADDRESS/wiki should get you to the Main Page of your wiki.

Additional Extensions

One may add the following additional extensions to enhance the MediaWiki environment:

MultimediaViewer

The MultimediaViewer extension gives the user of a wiki a different interface for viewing full-size, or nearly full-size, images in their browser without extraneous page loads or confusing interstitial pages.


Adding An Apache Virtual Host With Combined Logging

The following Apache include file is an example Virtual Host configuration with a Log Format suitable for AWStats processing: "/etc/httpd/conf.d/mediawiki.conf"

#
# This is for the BMC Wiki...
#
# - Setup an Apache Virtual Host...
# - Setup LogFormat for AWStat processing...

Listen 172.16.1.55:80

<VirtualHost 172.16.1.55:80>

DocumentRoot "/var/nst/mediawiki-1.9.0"
ServerName 11.222.133.44:80

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
TransferLog logs/bmcwiki_access_log
ErrorLog logs/bmcwiki_error_log
LogLevel warn

</VirtualHost>

<Directory "/var/nst/mediawiki-1.9.0">
  DirectoryIndex index.php
  Options ExecCGI
  Order allow,deny
  Allow from all
</Directory>

Alias /bmcwiki "/var/nst/mediawiki-1.9.0"

Backing Up The Wiki

Backing Up The Wiki Database

We use the following script to dump the SQL database containing the MediaWiki content. The script permits one to specify how many old backups to keep. We typically have cron run this script once a night and keep a weeks worth of backups immediately accessible.

#! /bin/bash

#
# nstwiki_mysql_backup --- PKB 2007

#
# Description: This script dumps the content of the MySQL Database
#              supporting the MediaWiki - NST WIKI
#
#        Note: Add symbolic soft link in /etc/cron.daily directory
#              for cron scheduling...

#
# Vars:
# =====
PKGDB="wikidb";
PKGSAVEDIR="/var/nst/backup/db";
PKGSAVEFILE="${PKGSAVEDIR}/nst${PKGDB}.sql.gz";

# How many backups to leave on system (must be 1 or larger)
declare -i PKGSAVECNT=7;

#
# Code:
# =====
. /etc/nst.conf || exit 1;

# Remove any unneed backups
declare -i i=${PKGSAVECNT};
while [ -f "${PKGSAVEDIR}/nst${PKGDB}${i}.sql.gz" ]; do
  /bin/rm -f "${PKGSAVEDIR}/nst${PKGDB}${i}.sql.gz";
  let i=i+1;
done

# Rename old backups (go from older to newer)
for ((i=PKGSAVECNT; i > 1;)); do
  g="${PKGSAVEDIR}/nst${PKGDB}${i}.sql.gz";
  i=$((i - 1));
  f="${PKGSAVEDIR}/nst${PKGDB}${i}.sql.gz";
  if [ -f "${f}" ]; then
    /bin/mv -f "${f}" "${g}";
  fi
done

# Rename last backup (if present)
if [ -f "${PKGSAVEFILE}" ]; then
  /bin/mv -f "${PKGSAVEFILE}" "${PKGSAVEDIR}/nst${PKGDB}1.sql.gz";
fi

# Dump database and save as current backup
[ -d "${PKGSAVEDIR}" ] || /bin/mkdir -p "${PKGSAVEDIR}" || exit 1;

nice /usr/bin/mysqldump \
  --host="127.0.0.1" \
  --user="root" \
  --password="${NSTCTMYSQLPASSWD}" \
  --add-drop-database \
  --add-drop-table \
  --databases "${PKGDB}" \
  | nice gzip -c \
  >| "${PKGSAVEFILE}";

#
# List backup compressed tar files...
printf "*** Listing backup directory: \"${PKGSAVEDIR}\"...\n";
/bin/ls -al --color=tty "${PKGSAVEDIR}";

#
# Terminate normally...
exit 0;

NOTE:

The above script is not suitable for a machine which is used for regular user accounts. This script is only acceptable for a system whose users will all have root access (the database password is passed on the command line and could be potentially captured in the output of a ps command). To secure this script for a public system, one would need to use the "expect" utility command in front of the "mysql" invocation.