MediaWiki

From MediaWiki
Revision as of 07:33, 21 February 2015 by Rwh (talk | contribs)
Jump to navigationJump to search

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

Adding MediaWiki

Set Up Database Server

MediaWiki requires access to a database. You can use either a MySQL or PostgreSQL database server. Both are available on a NST system.

Set Up MySQL

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

  • From the NST WUI menu bar, select: Database|MySQL|MySQL Database Management.
  • Scroll down to the Setup 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 MySQL Server button below the table to configure and start the MySQL 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 MySQL server. Once the page finishes loading, press the Return button to return back to the MySQL Database Service Management page.

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

This completes the set up of the MySQL 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.


Install MediaWiki Package(s)

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.

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 tell you that you need to move the config/LocalSettings.php file to its parent directory. You can complete this step by running the following command:

mv /var/www/wiki/config/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.