Difference between revisions of "MediaWiki"

From ArchWiki
Jump to: navigation, search
(Created page with "== Tips == === texvc === Usually installing texvc package and enabling it in config are enough: $wgUseTeX = true; If you get problems, try to increase limits for shell comman...")
 
(Configuration)
(36 intermediate revisions by 18 users not shown)
Line 1: Line 1:
 +
[[Category:Web Server]]
 +
{{Note| If you are using xampp, there are different steps you need to take after installing. More info [https://www.mediawiki.org/wiki/Manual:Running_MediaWiki_on_XAMPP#381 here] }}
 +
== Installation ==
 +
 +
Follow the [[LAMP|LAMP]] guide. Then [[pacman|Install]] {{pkg|php-gd}} and uncomment "extension=gd.so" in {{ic|php.ini}}, same for {{pkg|php-intl}} (needs icu) and {{pkg|php-xcache}} (here add "extension=xcache.so") and finally install {{pkg|mediawiki}}, all available from the [[official repositories]].
 +
 +
Instead of {{pkg|mysql}} you can install {{pkg|sqlite3}} or {{pkg|postgresql}}.
 +
 +
==Configuration==
 +
 +
Create {{ic|/etc/webapps/mediawiki/httpd-mediawiki.conf}} from the provided example {{ic|apache.example.conf}} in the same directory. Edit it to remove the {{ic|open_basedir}} line, which is already in {{ic|php.ini}}.
 +
 +
*Add the following lines to {{ic|/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 the open_basedir in {{ic|/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/
 +
* Adjust permissions in {{ic|/usr/share/webapps/mediawiki/.htaccess}}, e.g. to
 +
  allow from all
 +
 +
Restart apache with:
 +
# systemctl restart httpd
 +
 +
Open the wiki in a browser and do the initial setup to create {{ic|/usr/share/webapps/mediawiki/LocalSettings.php}}.
 +
 +
== Nginx ==
 +
To get MediaWiki working with Nginx, create the following file at {{ic|/etc/nginx/mediawiki.conf}}:
 +
 +
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 {{ic|php-fpm}} is installed, and in your {{ic|/etc/nginx/nginx.conf}} file, ensure that you have an {{ic|upstream}} directive named {{ic|php}}, similar to this one:
 +
 +
upstream php {
 +
  server unix:/var/run/php-fpm/php-fpm.sock;
 +
}
 +
 +
Include a server directive, similar to this, in your {{ic|/etc/nginx/nginx.conf}} file:
 +
 +
server {
 +
  listen 80;
 +
  server_name mediawiki;
 +
  root /usr/share/webapps/mediawiki;
 +
  index index.php;
 +
  include mediawiki.conf;
 +
}
 +
 +
Finally, ensure that the {{ic|open_basedir}} directive in {{ic|/etc/php/php.ini}} includes {{ic|/usr/share/webapps}} and {{ic|/etc/webapps}}, or you might get "File not found" or "No input file specified" errors.
 +
 
== Tips ==
 
== Tips ==
=== texvc ===
+
=== Mathematics (texvc) ===
  
 
Usually installing texvc package and enabling it in config are enough:
 
Usually installing texvc package and enabling it in config are enough:
Line 9: Line 79:
 
   $wgMaxShellFileSize = 1000000;
 
   $wgMaxShellFileSize = 1000000;
 
   $wgMaxShellTime = 300;
 
   $wgMaxShellTime = 300;
 +
 +
=== Unicode ===
 +
 +
Check that php, apache and mysql uses UTF-8. Otherwise you may face strange bugs because of encoding mismatch.

Revision as of 16:54, 10 December 2012

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

Installation

Follow the LAMP guide. Then Install php-gd and uncomment "extension=gd.so" in php.ini, same for php-intl (needs icu) and php-xcache (here add "extension=xcache.so") and finally install mediawiki, all available from the official repositories.

Instead of mysql you can install sqlite3 or postgresql.

Configuration

Create /etc/webapps/mediawiki/httpd-mediawiki.conf from the provided example apache.example.conf in the same directory. Edit it to remove the 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 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/
  • Adjust permissions in /usr/share/webapps/mediawiki/.htaccess, e.g. to
 allow from all

Restart apache with:

# systemctl restart httpd

Open the wiki in a browser and do the initial setup to create /usr/share/webapps/mediawiki/LocalSettings.php.

Nginx

To get MediaWiki working with Nginx, create the following file at /etc/nginx/mediawiki.conf:

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, in your /etc/nginx/nginx.conf file:

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

Finally, ensure that the open_basedir directive in /etc/php/php.ini includes /usr/share/webapps and /etc/webapps, or you might get "File not found" or "No input file specified" errors.

Tips

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;

Unicode

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