From NST Wiki
Revision as of 09:27, 26 February 2008 by Rwh (talk | contribs) (Adding An Apache Virtual Host With Combined Logging)
Jump to navigationJump to search

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

Adding MediaWiki

Use the NST System Patch Management page on the NST WUI to perform the initial installation. In addition:

  • You MUST setup the MySQL on the NST system.
  • You will probably want to setup the ntpd to keep the system clock synchronized.
  • You will probably want to adjust the Apache web server configuration file to allow others access to the system (see Apache Notes).

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



DocumentRoot "/var/nst/mediawiki-1.9.0"

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


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

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:
# =====

# 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;

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

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

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

nice /usr/bin/mysqldump \
  --host="" \
  --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;


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.