Install MediaWiki on Ubuntu 16.04
Updated by Linode Written by Stan Schwertly
MediaWiki is a popular, free wiki software package. It’s the same software Wikipedia uses. It is fully dynamic and runs on a LAMP stack, taking advantage of the PHP language and the MySQL database backend. With easy installation and configuration, MediaWiki is a good solution when you need a familiar, full-featured, dynamic wiki engine.
This guide assumes that you already have a working LAMP stack running on Ubuntu. Your web accessible
DocumentRoot should be located in
/var/www/html/example.com/public_html/. You should be connected to your server via SSH and logged in as root.
Download and Unpack MediaWiki
Change your working directory to Apache’s
DocumentRootand download the latest release of MediaWiki. As of this writing, the latest stable release of MediaWiki is version 1.29.0.
cd /var/www/html/example.com/ curl -O https://releases.wikimedia.org/mediawiki/1.29/mediawiki-1.29.0.tar.gz
You will want to check for the latest version of this software regularly and upgrade to avoid allowing your site to become vulnerable to known security bugs. You can find the download location for the latest release by visiting the MediaWiki homepage.
Decompress the package:
tar -xvf mediawiki-1.29.0.tar.gz
Move the uncompressed
mediawiki-1.29.0directory into your site’s
public_html/folder, renaming the directory to
mediawiki/in the process.
mv mediawiki-1.29.0/ public_html/mediawiki/
The name of the directory beneath the
public_html/ will determine the path to your wiki. In this case, the wiki would be located at
example.com/mediawiki/. You can copy the wiki to any publicly accessible location in the
Mediawiki needs to communicate with a database to store information. Create a database and a user with a secure password, then grant all privileges on the new database to the user.
CREATE DATABASE my_wiki; CREATE USER 'media_wiki'@'localhost' IDENTIFIED BY 'password'; GRANT ALL ON my_wiki.* TO 'mediawiki'@'localhost' IDENTIFIED BY 'password';
Point your browser to the URL of your wiki, for example:
example.com/mediawiki/ and click the “Please set up the wiki first” link. The setup page contains everything you need to complete the installation.
From the database section above, you will need: - The database name - DB username - DB user’s password
Giving MediaWiki superuser access to your MySQL database allows it to create new accounts. If you plan on having a large number of users or content, consider setting up a second Linode as a dedicated database server.
After the installation is finished, MediaWiki will create a
LocalSettings.php file, with the configurations from the installation process. Move the
LocalSettings.php file to
/var/www/html/example.com/public_html/mediawiki/ and restrict access to the file:
chmod 700 /var/www/html/example.com/public_html/media/wiki/LocalSettings.php
MediaWiki is now successfully installed and configured!
You can monitor the MediaWiki development mailing list to ensure that you are aware of all updates to the software. When upstream sources offer new releases, repeat the instructions for installing the MediaWiki software as needed.
You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.
Join our Community
This guide is published under a CC BY-ND 4.0 license.