Development

install-mediawiki-on-debian

Captain Salem 2 min read

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/. If you are running the server on remote location, login to root with SSH.

Download and Unpack MediaWiki

Move the uncompressed mediawiki-1.34.2 directory into your site’s public_html/ folder, renaming the directory to mediawiki/ in the process.

sudo mv mediawiki-1.34.2/ 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 public_html/ hierarchy.

Decompress the package:

sudo tar -xvf mediawiki-1.33.0.tar.gz

Change your working directory to Apache’s DocumentRoot and download the latest release of MediaWiki. As of this writing, the latest stable release of MediaWiki is version 1.33.0.

cd /var/www/html/example.com/
sudo curl -O https://releases.wikimedia.org/mediawiki/1.34/mediawiki-core-1.34.2.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.

Configure MySQL

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 a database and a user with permissions for it. In this example, the database is called wikidb, the user wiki_admin, and password mywikipasswd. Be sure to enter your own password. This should be different from the root password for MySQL:

CREATE DATABASE wikidb;
CREATE USER 'wiki_admin'@'localhost' IDENTIFIED BY 'mywikipasswd';
GRANT ALL ON my_wiki.* TO 'media_wiki'@'localhost' IDENTIFIED BY 'password';

Log in using the MySQL root password:

sudo mysql -u root -p

Configure MediaWiki

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.

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:

sudo chmod 700 /var/www/html/example.com/public_html/media/wiki/LocalSettings.php

MediaWiki is now successfully installed and configured!

Share
Comments
More from Cloudenv

Cloudenv

Developer Tips, Tricks and Tutorials.

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to Cloudenv.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.