Manual:Running MediaWiki on Debian or Ubuntu/zh

这个页面讲解如何在 Debian 或Ubuntu GNU/Linux 服务器上安装 MediaWiki. 下面是以 Debian 为例进行说明，也适用于 Ubuntu 和 Raspbian，不一样的地方会特别标明.

Introduction
This installation procedure requires knowledge of issuing commands from a terminal (e.g. installing applications) and using a text editor (e.g. graphical: gedit, kate; text: nano, emacs, vi).

When text editing is required it can be carried out on the graphical desktop by pressing Alt-F2 and typing

gksudo gedit 文件名

Alternatively, editing can be done from a terminal

sudo nano 文件名

Of course, kate could be used instead of gedit or vi/emacs instead of nano.

确保您的 Debian 系统是最新的
Double check that Debian is up-to-date by running:

or in one line

安装 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:

可选的有用软件包
These packages are not necessary but may be useful, depending on the installation:

你可以通过  安装以上的任意一个包.

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

安装 MediaWiki
你可以从浏览器或命令行下载
 * 下载官方压缩包.

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


 * 解压到你的 Web 目录里

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

You will have to:


 * create a NEW mysql user (new_mysql_user):

# sudo mysql -u root -p and enter password of mysql root user (if you have no configured password it will be empty, so just press return)

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


 * create a NEW mysql database my_wiki:

# sudo mysql -u root 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>quit;

可选操作：配置 PHP
编辑你的 PHP 配置文件，php.ini. 在 Ubuntu Trusty 和 Debian Jessie 上，这个文件位于.

On Ubuntu Xenial and Debian Stretch (PHP 7), it is located at.

最大上传文件大小
假设要将各种文件上传到 Wiki 作为内容，则必须调整上传文件的最大大小限制. 大约在文件上传小节的下半部分. 修改以下语句： 将上传大小上限调整到至少 20M. 将来你需要上传更大的文件时，你可能需要再次调整这个值.

内存限制
一些 PHP 脚本运行时需要很多内存. To increase the maximum amount of memory a script can use, page down to about 21%, and change the following entry, if found, from to If it is already set to 128M or more, leave it as is.

配置 MediaWiki
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 following the procedure given.

If this gives a 404 error then working a symbolic link should solve it:

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

This can solve a lot of problems by specifically identifying the source of any errors.
 * Pay close attention for "Checking environment..." in MediaWiki installation script.

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

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

Fill out all the field in the configuration form and press to continue button. You will have to use your username and password provided 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: debian-sys-maint 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

基本信息
MediaWiki is configured by the LocalSettings.php file, usually found in. has detailed information that may be useful. The following are changes that appear to be universally helpful

To edit LocalSettings.php use

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

or from a terminal

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

文件上传
参见.

更改 Logo
参见.

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.

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

參見

 * Canonical maintains a MediaWiki page with more information
 * Debian MediaWiki page
 * Ubuntuguide.org provides detailed instructions for setting up MediaWiki on Ubuntu and Kubuntu, including multiple wikis and nested subwikis.
 * Start to end Mediawiki Setup Guide at ofswiki.org, closely referencing official docs, support for multiple distros including Debian/Ubuntu, automation and a minimal style