MediaWiki + Ubuntu 11.04 & Customizations

Recently, I setup a personal wiki for myself since I’m always encountering more information than I have time to read, but always want to go back later. Its also a way for me to organize topics I don’t know as much about as I’d like so that I can remember to come back to those areas later on. (Inspired by fellow UoG Student Eddia Ma: http://eddiema.ca/wiki/) The default install from Ubuntu is pretty simple. I just installed it with the expected:

sudo apt-get install mediawiki

There are some simple steps to follow as you install with the package manager such as setting up the database and first configuration which should be easy enough to get through. However, the wiki required much customization before it would be good for what I was planning on using it for.

Citation Support

First of all, it had to support citations so that I could source the original papers, websites and others. This required the Cite Extension which can be downloaded here: http://www.mediawiki.org/wiki/Special:ExtensionDistributor/Cite (make sure you select the version that corresponds to the mediawiki version you have installed. Next extract to your extensions folder (likely /var/lib/mediawiki/extensions/ on Ubuntu 11.04). Finally add the following line to your mediawiki configuration file LocalSettings.php (likely in /etc/mediawiki).

require_once("$IP/extensions/Cite/Cite.php");

Attachments

I wanted to be able to attach papers directly into my wiki (pdfs and other documents from academic papers). For this I had to add the following line to my LocalSettings.php file (likely in /etc/mediawiki):

$wgFileExtensions = array('png','gif','jpg','jpeg','doc','xls','mpp','pdf','ppt','tiff','bmp','docx', 'xlsx', 'pptx','ps','odt','ods','odp','odg');

Additionally, I encountered problems uploading many larger pdfs since they are larger than the default php upload size. In ubuntu, this can be changed by modifying the php.ini file (likely located in /etc/php5/apache). Look for ‘upload_max_filesize’ and ‘post_max_size’ in order to change this to whatever size you like.

Math!

Of course being a CS student, I need to be able to add math equations into my wiki. The math formulas are entered using Latex which most CS grad students (and many undergrads) should know how to use. This one is in the Ubuntu repositories so it is easy to do:

sudo apt-get install mediawiki-math

Then you have to edit the LocalSettings.php file again (/etc/mediawiki) so that the wgUseTex flag is true:

$wgUseTeX = true;

Source Code – Syntax Highlighting

Again since I am a CS student, my wiki needs to be able to display source code easily in a readable way. For this I use the Ubuntu package manager again:

sudo apt-get install mediawiki-extensions-geshi

And edit the LocalSettings.php file (/etc/mediawiki) – For some reason, other instructions I have online have different paths and names for the plugin, so this will only work using the plugin from the repository. If you download it yourself directly, the name and location may be different:

require_once("$IP/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php");

Wiki Privacy

Lastly, as I previously mentioned the wiki is private (at least for now). To do this it is quite simple. Just paste this into the bottom of your LocalSettings.php file. (There are other variations on how private you can make the wiki, but if you want to do that, check out the official mediawiki page)

# Disable reading by anonymous users
# See: http://www.mediawiki.org/wiki/Manual:Preventing_access#Restrict_viewing_of_all_pages
$wgGroupPermissions['*']['read'] = false;

# But allow them to access the login page or else there will be no way to log in!
# NOTE: You also need to provide access here to the .css and .js files that the
# allowed pages attempt to load; otherwise, users will get errors on the page
# when they attempt to load it (IE will complain about the errors;
# FF will show them in its error console)
# [You also might want to add access to "Main Page", "Wikipedia:Help", etc.)
$wgWhitelistRead = array ("Special:Userlogin", "MediaWiki:Common.css",
"MediaWiki:Common.js", "MediaWiki:Monobook.css", "MediaWiki:Monobook.js", "-");

# Disable anonymous editing
$wgGroupPermissions['*']['edit'] = false;

# Prevent new user registrations except by sysops
$wgGroupPermissions['*']['createaccount'] = false;