MediaWiki

From NST Wiki
Revision as of 10:35, 25 October 2010 by Paul Blankenbaker (talk | contribs)
Jump to navigationJump to search

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

Adding MediaWiki

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

yum 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.

After installation completes, you will need to setup 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:

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.



Install Package(s)

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.