Jump to content

Manual:Running MediaWiki on Debian or Ubuntu

From mediawiki.org
This page is a translated version of the page Manual:Running MediaWiki on Debian or Ubuntu and the translation is 42% complete.
This page documents how to install MediaWiki using the release tarballs. If you want to use system packages, and are not installing on Raspbian see Debianパッケージ .

このページでは、Debian や Ubuntu の GNU/Linux サーバー上で MediaWiki をインストールする方法を説明します。 The instructions below refer to Debian, but unless otherwise noted also apply to Ubuntu and Raspbian.



テキストの編集が必要とされる場合には、GUI環境では Alt+F2 をおした後に以下のように入力します:

gksudo gedit ファイル名


sudo nano ファイル名



Ensure Debian is up-to-date


sudo apt update
sudo apt upgrade

or in one line

sudo apt update && sudo apt upgrade

LAMP スタックのインストール

Ubuntu Server Edition makes LAMP (Apache, PHP, and MySQL) available for installation during the install process. During the installation step, make sure you choose to install a LAMP server. Alternately, you can install all of these packages from a standard installation using these commands:

sudo apt-get install apache2 mariadb-server php php-mysql libapache2-mod-php php-xml php-mbstring
Alternately you can use mysql (Raspberry Pi OS no longer supports mysql).
sudo apt-get install apache2 mysql-server php php-mysql libapache2-mod-php php-xml php-mbstring

Optional useful packages

These packages are not necessary but may be useful, depending on the installation:

名前 パッケージ 説明
代替 PHP キャッシュ php-apcu Modern MediaWiki versions will automatically take advantage of this being installed for improved performance.
PHP Unicode normalization php-intl MediaWiki will fallback to a slower PHP implementation if not available.
ImageMagick imagemagick Image thumbnailing.
Inkscape inkscape Alternative means of SVG thumbnailing, than ImageMagick. Sometimes it will render SVGs better if originally created in Inkscape.
PHP GD library php-gd Alternative to ImageMagick for image thumbnailing.
PHP command-line php-cli Ability to run PHP commands from the command line, which is useful for debugging and running maintenance scripts.
PHP cURL php-curl Required by some extensions such as Extension:Math . See Manual:cURL
git source control version git If not present config script will tell you that it is not installed
Basic Calculator php-bcmath In order to make the visualeditor work on 32bit machines, like a raspi

You can install any of the above with sudo apt-get install packagename.

If you want to install all of them:

sudo apt-get install php-apcu php-intl imagemagick inkscape php-gd php-cli php-curl php-bcmath git

If you install php-apcu you will have to reload your apache configuration in order to avoid a warning message when running configuration script:

sudo systemctl reload apache2

MediaWiki のインストール

This can be done from a browser or by command line

cd /tmp/ wget https://releases.wikimedia.org/mediawiki/1.42/mediawiki-1.42.1.tar.gz

  • extract in your Web directory
tar -xvzf /tmp/mediawiki-*.tar.gz
sudo mkdir /var/lib/mediawiki
sudo mv mediawiki-*/* /var/lib/mediawiki

Configuring MySQL

But before proceeding with the initial MediaWiki installation, there are certain steps you need to do first!

On Raspbian, if this is a new installation of mariadb you will also need to run: sudo mysqld_safe --skip-grant-tables --skip-networking &

You will have to:

  • create a NEW mysql user (new_mysql_user):
# sudo mysql -u root -p 
Enter password: Enter password of mysql root user (if you have not configured password it will be blank, so just press enter)
mysql> CREATE USER 'new_mysql_user'@'localhost' IDENTIFIED BY 'THISpasswordSHOULDbeCHANGED';
mysql> quit;
  • create a NEW mysql database my_wiki:
# sudo mysql -u root -p
mysql> CREATE DATABASE my_wiki;
mysql> use my_wiki;
Database changed
  • GRANT the NEW mysql user access to the NEW created mysql database my_wiki:
mysql> GRANT ALL ON my_wiki.* TO 'new_mysql_user'@'localhost';
Query OK, 0 rows affected (0.01 sec)
mysql> commit;
mysql> quit;


これらのステップはシンプルに経験に基づいたものです。 このステップをすべてスキップできます(もしくは後でも十分で行うことができます)

Edit your PHP configuration file, php.ini . It is located at /etc/php/7.*/apache2/php.ini, depending on exact version of PHP.


様々なファイルがWikiにコンテンツとしてアップロードされることを想定すると、アップロード可能なファイルサイズの上限を調整しなければなりません。 このセクションの後半の半分はファイルのアップロードに関することを取り扱います。 変更

upload_max_filesize = 2M

少なくとも20Mです。 将来再びこの値を変更しなければならないことがあります。


Some PHP scripts require a lot of memory to run. To increase the maximum amount of memory a script can use, page down to about 21%, and change the following entry, if found, from

memory_limit = 8M


memory_limit = 128M

If it is already set to 128M or more, leave it as is.


Navigate your browser to http://localhost/mediawiki (for certain installations it may be http://localhost/mediawiki/config or http://wiki.hostname.com/config instead) and follow the procedure given.

If this gives a 404 error then working a symbolic link should solve the issue.

sudo ln -s /var/lib/mediawiki /var/www/html/mediawiki

For Debian based systems running apache2, once you create a symbolic link in the /var/www/html directory you may still run into a 404 error. If this happens, try loading: localhost/html/mediawiki/.

MediaWikiのインストールスクリプトで"Checking environment..."を注目して下さい。


It may complain that php extensions like mbstring and xml are missing even though you have installed them. Please manually activate them by using:

sudo phpenmod mbstring
sudo phpenmod xml
sudo systemctl restart apache2.service

設定フォームのすべての欄に記入して、続行ボタンを押してください。 Use the username and password which you provided as above in the mysql configuration section:

mysql> CREATE USER 'new_mysql_user'@'localhost' IDENTIFIED BY 'THISpasswordSHOULDbeCHANGED';

Under Database Config, you may change the database name and DB username to new values, but you must turn on "Use superuser account", name:


giving the mysql root password you configured earlier.

The configuration process will prompt you to download a LocalSettings.php that must be saved to the parent directory of the new wiki. The configuration page will give the exact directory/filename that must be moved:

sudo mv ~/Downloads/LocalSettings.php /var/lib/mediawiki/

And navigate your browser to http://localhost/mediawiki (or http://server_ip_address/mediawiki or http://server_ip_address/mediawiki/index.php) to see your new wiki.

やりました! 稼働しているwikiを手に入れました!!



ウィキは /var/lib/mediawiki にある LocalSettings.php ファイルで設定変更できます。 Manual:LocalSettings.php に、役立つかもしれない詳細情報があります。 次は一般的に役立つと思われる変更です。

LocalSettings.php を編集するには以下を使用します

gksudo gedit /var/lib/mediawiki/LocalSettings.php

or from a terminal

sudo nano /var/lib/mediawiki/LocalSettings.php


Manual:ファイルのアップロードの設定 を参照してください。


Manual:$wgLogos (1.35+) または Manual:$wgLogo を参照してください。

MediaWiki 拡張機能

The current tarball for MediaWiki comes with a package of 15 or so of the most popular extensions, but there are literally hundreds more.

Instructions on how to enable extensions can be found at Manual:拡張機能 .

Pretty URLs

To use /wiki/* instead of /wiki/index.php/* on Debian, follow the recommended short URL guide using '/mediawiki' as the script path instead of '/w' and placing the rewrites in /etc/apache2/conf-enabled/mediawiki.conf.