Installing Mediawiki

From Shrubbery

Jump to: navigation, search

I decided to take the plunge and install MediaWiki. Unlike XWiki, it isn't written in Java so of course it doesn't use Hibernate, but I'm getting kind of tired of XWiki's inability to have backlinks, etc. (see: ComparingXWikiAndMediaWiki)

Contents


Installation Steps

Download MediaWiki: http://www.mediawiki.org/wiki/Download

Read the Installation Guide

Setting up Apache and PHP

I had to install a few PHP things to get it to work. The first was the mysql driver for PHP. The other allows PHP to send email.

# yum install php-mysql php-pear-Mail

Enable apache if it isn't already enabled:

# chkconfig httpd on
# chkconfig --list | grep httpd
httpd           0:off   1:off   2:on    3:on    4:on    5:on    6:off
# service httpd start

Create the database

Create the database, for example using mysql:

[root@myhost wiki]# mysql -u root -p mysql
... enter password ...
mysql> create database wikidb;
mysql> grant create, select, insert, update, delete, lock tables on wikidb.* to 'wikiuser'@'localhost' identified by 'password';
mysql> flush privileges;

Disabling Anonymous Edits

I edited LocalSettings.php to dissallow anonymous editing as well:

# This snippet prevents editing from anonymous users
$wgGroupPermissions['*']['edit'] = false;

See these pages for more:

Configuring file uploads

See:

Eliminating index.php from the URLs

See Short URLs for MediaWiki

Troubleshooting

Well, it seems to be working but I can't seem to find a way to see what problem the e-mail feature is having. So, I have to figure out how to turn on logging for PHP.

http://mail.wikipedia.org/pipermail/mediawiki-l/2006-February/010066.html

Enable PHP Logging

Seems pretty easy. On my linux box I edited /etc/php.ini so syslog is enabled.

; Log errors to syslog (Event Log on NT, not valid in Windows 95).
error_log = syslog

File uploads don't work for some file types

I had a little problem with uploading 'png' files. This approach fixed the problem:

Basically I just added the following to LocalSetting.php near where $wgEnableUploads:

$wgMimeDetectorCommand= "file -bi"; #use external mime detector

Syle sheets aren't loading

If the MediaWiki installation directory is associated with the same URL as the 'short url' alias, then the resource references on the main wiki HTML pages are going to go through the alias instead of getting served via the filesystem.

Solution: Move the MediaWiki installation to a different directory (for example: /var/www/html/w) and change $wgScriptPath to refer to this (for example, "/w").

Thumbnails aren't working

If MediaWiki Image references aren't thumbnailing, check the following:

  • Look for $wgUseImageResize in LocalSettings.php, if it's set to false then thumbnails won't be created.
  • Make sure the ImageMagick package is installed. Look for /usr/bin/convert. If it isn't installed:
yum install -y ImageMagick
  • Try commenting out $wgUserImageResize = false; and uncommenting:
$wgUseImageMagick = true;
$wgImageMagickConvertCommand = "/usr/bin/convert";

Math not working

The following packages are required: ImageMagick tetex-dvips tetex-latex ocaml gcc

See http://meta.wikimedia.org/wiki/Troubleshooting_math_errors

Here is an example of what I had to do to get math notation working on an FC6 box:

# yum install -y ImageMagick tetex-dvips tetex-latex ocaml gcc
# cd /var/www/html/w/math
# make
# cd ..
# vi LocalSettings.php
... change $wgUseTeX ...
$wgUseTeX = true;

Locked out / Lost Password

See http://e-huned.com/2006/08/15/reset-a-mediawiki-password

$ mysql -u wikidbuser -p wikidb
mysql> update user set user_password = md5(concat(user_id,'-',md5('NewPassword'))) where user_name='WikiSysop';

Getting email to work

The e-mail notification requires the 'pear Mail' module for PHP, which can be installed like this on FC6:

# yum install php-pear-Mail

Add the following to LocalSettings.php:

# Sending e-mails (requires php-pear-Mail)
$wgSMTP = array(
 'host'     => "smtp.myisp.net",
 'IDhost'   => "earthlink.net",
 'port'     => 25,
 'auth'     => true,
 'username' => "my_isp_username",
 'password' => "my_isp_password"
);

Well, turning on the logging may tell you that the webserver cannot access the pear Mail package, but that didn't seem to be the case with my installation. It looks like I was just using the wrong 'IDHost'.


Notes about Media Wiki e-mail

  • It works well with ISP e-mail SMTP servers that are not encrypted (because they know which IP address the requests are coming from).
  • It does not work well with TLS SMTP servers such as GMail. All my attempts at getting this to work resulted in the httpd hanging. Something you may want to do in any case is to set up a Postfix eMail Relay on the server. This way MediaWiki can simply use SMTP to connect to 'localhost' and the messages will be forwarded to the ISP via postfix.

MediaWiki eMail Setup Links

Debugging MediaWiki

See http://meta.wikimedia.org/wiki/How_to_debug_MediaWiki


Upgrading Mediawiki

Follow these instructions: http://www.mediawiki.org/wiki/Manual:Upgrading

You may need to add a new MySQL user for the 'wikidb' database. For example:

$ mysql -u root -p mysql
password: ...
mysql> grant all on wikidb.* to 'wikiadmin'@'localhost' identified by 'adminpass';
mysql> flush privileges;

You should be able to copy over all the files in the following directories after the upgrade:

  1. Image files in the images directory.
  2. New or custom skins in the skins directory.
  3. Extensions in the extensions directory.
Personal tools