From MattWiki
(Redirected from Mediawiki)
Jump to: navigation, search

Installing MediaWiki on a Nginx web server

Here is my quick guide to use MediaWiki on a Nginx server using php-fpm.

There are many ways of doing this. I like pretty url's, so this configuration will remove the index.php from the url. This is great, but it will not redirect links to index.php to the new none index.php links. You also need to configure MediaWiki to use short urls. Also, the below configuration dose assume your using Unix socket connections to php-fpm.

So here we go, inside your http { block, add the following.


    server {
        listen 80;
        root /var/www/;
        include mediawiki.conf;


# MediaWiki Config
location ~ \.htaccess {
        deny all;

location ~* /sitemaps/ {
        autoindex  on;

# Remove index.php from URI
rewrite ^/index.php/(.*) /$1  permanent;

location / {
        if (!-e $request_filename) {
                rewrite ^/([^?]*)(?:\?(.*))? /index.php?title=$1&$2 last;
        if ($uri ~* "\.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$") {
                expires max;

location ~* \.php$ {
        if (!-e $request_filename) {
                return 404;

        include /etc/nginx/fastcgi_params;

        fastcgi_pass  unix:/var/run/php-fpm.socket;
        fastcgi_index index.php;

        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

If you only have a single wiki on your server, there's really no reason to create a new mediawiki.conf file, but instead just add it to the server block.

Installing the Math Plugin

apt-get -y install ko.tex-extra-hlfont latex-cjk-all latex-cjk-chinese latex-cjk-chinese-arphic-bkai00mp \
  latex-cjk-chinese-arphic-bsmi00lp latex-cjk-chinese-arphic-gbsn00lp latex-cjk-chinese-arphic-gkai00mp \
  latex-cjk-common latex-cjk-japanese latex-cjk-japanese-wadalab latex-cjk-korean latex-cjk-thai \
  latex-cjk-xcjk latex-fonts-thai-tlwg libaprutil1-dbd-sqlite3 swath texlive-xetex thailatex

Next change into your MediaWiki directory and into the Math subdirectory

cd extensions/Math/math

And run make


Now you need to make texvccheck

cd extensions/Math/texvccheck/

And run make


After the install, you need to set your conf as following:

### Math ###
require_once( "$IP/extensions/Math/Math.php" );

Math Examples

Once your done, you may enter a math formula such as:

  \operatorname{erfc}(x) =
  \frac{2}{\sqrt{\pi}} \int_x^{\infty} e^{-t^2}\,dt =
  \frac{e^{-x^2}}{x\sqrt{\pi}}\sum_{n=0}^\infty (-1)^n \frac{(2n)!}{n!(2x)^{2n}}

This will produce:

or a more simpler:


will produce:

or even pi (π):

<math> \pi = \frac{C}{d}</math>

will produce:

Configuration Changes

How to modify the right hand menu


Building MediaWiki Sitemap

Build a script to be put in your server's crontab.

cd /var/www/
rm -f sitemap*
/usr/bin/php /var/www/ --server --urlpath
ln sitemap-index-mattrude_com_wiki.xml sitemap.xml

User Namespace

ID Name
0 Main
1 Main Talk
2 User
3 User Talk
4 Project
5 Project Talk
6 File
7 File Talk
8 MediaWiki
9 MediaWiki Talk
10 Template
11 Template Talk
12 Help
13 Help Talk
14 Category
15 Category Talk

How to Patch MediaWiki

Download the patch file inside your wiki folder.


Then to patch it run.

patch -p0 -i mediawiki-1.9.3.patch

MediaWiki Tips & Tricks

To change the way the title is displayed on pages:


so for example to change the name PhpLDAPadmin to phpLDAPadmin add the following.