Difference between revisions of "MediaWiki"

From NST Wiki
Jump to navigationJump to search
(Adding An Apache Virtual Host With Combined Logging)
(Adding MediaWiki)
Line 1: Line 1:
 
This page contains some notes related to using a '''NST''' system as a [http://www.mediawiki.org MediaWiki] server.
 
This page contains some notes related to using a '''NST''' system as a [http://www.mediawiki.org 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 =
 
= Adding An Apache Virtual Host With Combined Logging =

Revision as of 10:18, 25 October 2010

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

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.