Difference between revisions of "MediaWiki"

From ArchWiki
Jump to: navigation, search
m (Apache: Clarified which line to remove.)
m (Configuration: Fixed link to Daemons)
Line 31: Line 31:
{{bc|allow from all}}
{{bc|allow from all}}
[[Pacman|Restart]] the {{ic|httpd.service}} daemon.
[[Daemons|Restart]] the {{ic|httpd.service}} daemon.
==== Nginx ====
==== Nginx ====

Revision as of 09:55, 21 January 2013

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


You need to have a web server installed, configured to be able to use php. You can follow the LAMP guide for that purpose.

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

Instead of mysql you can use sqlite (which requires php-sqlite and sqlite) or postgresql.


First, adjust the open_basedir in /etc/php/php.ini to include the webapps directory (allows update.php to be run from the command line):

open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/

Then, still on /etc/php/php.ini, look for the Dynamic Extensions section and uncomment ;extension=gd.so, uncomment ;extension=intl.so and add extension=xcache.so.

Now do the steps corresponding to your web server.

Web server


Create /etc/webapps/mediawiki/httpd-mediawiki.conf from the provided example apache.example.conf in the same directory. Edit it to remove the php_admin_value open_basedir line, which is already in php.ini.

  • Add the following lines to /etc/httpd/conf/httpd.conf
LoadModule php5_module modules/libphp5.so
Include conf/extra/php5_module.conf
Include /etc/webapps/mediawiki/httpd-mediawiki.conf
  • Adjust permissions in /usr/share/webapps/mediawiki/.htaccess, e.g. to
allow from all

Restart the httpd.service daemon.


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


location / {
   index index.php;
   try_files $uri @mediawiki;
location @mediawiki {
   rewrite ^/([^?]*)(?:\?(.*))? /index.php?title=$1$2 last;
location ~ \.php?$ {
   include fastcgi.conf;
   fastcgi_pass php;
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
   try_files $uri /index.php;
   expires max;
   log_not_found off;
location ^~ /maintenance/ {
   return 403;
location ^~ /cache/ {
   deny all;

Ensure that php-fpm is installed, and in your /etc/nginx/nginx.conf file, ensure that you have an upstream directive named php, similar to this one:

upstream php {
   server unix:/var/run/php-fpm/php-fpm.sock;

Include a server directive, similar to this

server {
  listen 80;
  server_name mediawiki;
  root /usr/share/webapps/mediawiki;
  index index.php;
  include mediawiki.conf;


You should have Lighttpd installed and configured. Append to the lighttpd configuration file the following lines

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.


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 package and enabling it in config are enough:

$wgUseTeX = true;

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

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


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