MediaWiki

Note: If you are using xampp, instead of LAMP, there are different steps you need to take after installing. More info here

Installation

You need to have a web server, such as Apache installed, configured to be able to use PHP.

Install the php-gd, php-intl and mediawiki, all available from the official repositories.

You will also need a database, such as MySQL, PostgreSQL, or sqlite (php-sqlite and sqlite).

Configuration

The steps to achieve a working MediaWiki configuration involve editing the PHP settings and adding the MediaWiki configuration snippets.

PHP

First, adjust the open_basedir in /etc/php/php.ini to include the mediawiki data directory (/var/lib/mediawiki by default):

/etc/php/php.ini
open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/:/var/lib/mediawiki/

Then, also in /etc/php/php.ini, uncomment the following lines: (in the Dynamic Extensions section)

extension=gd.so
extension=intl.so
Note:
  • If you would like to use SQLite as database, also uncomment extension=pdo_sqlite.so if using MariaDB uncomment extension=mysqli.so.
  • Since MediaWiki 1.24, it is necessary to also uncomment extension=iconv.so.

Second, tweak the session handling or you might get a fatal error (PHP Fatal error: session_start(): Failed to initialize storage module[...]) by finding the session.save_path path. A good choice can be /var/lib/php/sessions or /tmp/.

/etc/php/php.ini
session.save_path = "/var/lib/php/sessions"

You will need to create the directory if it doesn't exist and then restrict its permissions:

# mkdir -p /var/lib/php/sessions/
# chown http:http /var/lib/php/sessions
# chmod go-rwx /var/lib/php/sessions

Web server

Apache

Copy /etc/webapps/mediawiki/apache.example.conf to /etc/httpd/conf/extra/mediawiki.conf and edit it as needed.

Add the following lines to /etc/httpd/conf/httpd.conf

Include conf/extra/mediawiki.conf

Restart the httpd.service daemon.

Nginx

To get MediaWiki working with Nginx, create the following file:

/etc/nginx/mediawiki.conf

location / {
   index index.php;
   try_files $uri $uri/ @mediawiki;
}
location @mediawiki {
   rewrite ^/(.*)$ /index.php?title=$1&$args;
}
location ~ \.php5?$ {
   include /etc/nginx/fastcgi_params;
   fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
   fastcgi_index index.php5;
   fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
   try_files $uri @rewrite;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
   try_files $uri /index.php;
   expires max;
   log_not_found off;
}
# Restrictions based on the .htaccess files
location ^~ ^/(cache|includes|maintenance|languages|serialized|tests|images/deleted)/ {
   deny all;
}
location ^~ ^/(bin|docs|extensions|includes|maintenance|mw-config|resources|serialized|tests)/ {
   internal;
}
location ^~ /images/ {
   try_files $uri /index.php;
}
location ~ /\. {
   access_log off;
   log_not_found off; 
   deny all;
}

Ensure that php-fpm is installed and started.

Include a server directive, similar to this

/etc/nginx/nginx.conf
server {
  listen 80;
  server_name mediawiki;
  root /usr/share/webapps/mediawiki;
  index index.php;
  charset utf-8;
# For correct file uploads
  client_max_body_size    100m; # Equal or more than upload_max_filesize in /etc/php/php.ini
  client_body_timeout     60;
  include mediawiki.conf;

}

Finally, restart the nginx.service daemon.

Lighttpd

You should have Lighttpd installed and configured. "mod_alias" and "mod_rewrite" in server.modules array of lighttpd is required. Append to the lighttpd configuration file the following lines

/etc/lighttpd/lighttpd.conf
alias.url += ("/mediawiki" => "/usr/share/webapps/mediawiki/")
url.rewrite-once += (
                "^/mediawiki/wiki/upload/(.+)" => "/mediawiki/wiki/upload/$1",
                "^/mediawiki/wiki/$" => "/mediawiki/index.php",
                "^/mediawiki/wiki/([^?]*)(?:\?(.*))?" => "/mediawiki/index.php?title=$1&$2"
)

Restart the lighttpd.service daemon.

LocalSettings.php

Open the wiki url (is http://your_server/mediawiki/) in a browser and do the initial setup to create LocalSettings.php. Then save it to /usr/share/webapps/mediawiki/LocalSettings.php.

Tips and tricks

Mathematics (texvc)

Usually installing texvc and enabling it in the config are enough:

$wgUseTeX = true;

If you get problems, try to increase limits for shell commands:

$wgMaxShellMemory = 8000000;
$wgMaxShellFileSize = 1000000;
$wgMaxShellTime = 300;

Unicode

Check that php, apache and mysql uses UTF-8. Otherwise you may face strange bugs because of encoding mismatch.

VisualEditor

After following this instruction on how to install the VisualEditor, you need a backend nodejs application on your server, called Parsoid, to get it finally working.

Simply install parsoid-git from the AUR and adjust the path to your MediaWiki in following file:

/usr/share/webapps/parsoid/api/localsettings.js
parsoidConfig.setInterwiki( 'localhost', 'http://localhost/mediawiki/api.php' );

After that simply enable and start parsoid.service.

Other Extensions

Usually extensions are located in /usr/share/webapps/mediawiki/extensions and managing them manually may, over time, be more work than creating a package in AUR. See mediawiki-ext-confirmaccount-git[broken link: package not found] and mediawiki-ext-usermerge-git[broken link: package not found] for examples.