Atlantic.Net Blog

How to Install MediaWiki on Ubuntu 20.04

Arnaldo Arrieta
by Atlantic.Net (3 posts) under Tutorials, VPS Hosting
0 Comments

MediaWiki is a wiki application written in PHP that the Wikimedia Foundation developed to run several of their projects. The encyclopedia Wikipedia is the most popular of these projects.

A wiki is a type of website that allows its users to create and edit content in a collaborative manner. It can be used in several ways, including as a knowledge base, documentation library, community website, or company intranet.

These kinds of websites are especially useful in contexts where several people need to create and modify pages in a quick and easy way.

This guide will show you how to install and set up the application, giving you the basis to deploy your own wiki site.
We will use the domain name “mediawiki.example.com” in this guide. Replace it with the domain name or IP address you have configured on your server.

Prerequisites

  • An Ubuntu 20.04 server. You can run MediaWiki on a different flavor of GNU/Linux, but the steps outlined below could differ. If you do not have one, why not spin up a fast SSD virtual private server from Atlantic.Net.
  • A root password is set up on the server.

Step 1 – Create Atlantic.Net Cloud Server

First, log in to your Atlantic.Net Cloud Server. Create a new server, choosing Ubuntu 20.04 as the operating system with at least 2GB RAM. Connect to your Cloud Server via SSH and log in using the credentials highlighted at the top of the page.

Once you are logged in to your Ubuntu 20.04 server, run the following command to update your base system with the latest available packages.

apt-get update -y

Step 2 – Install LAMP Server

First, you will need to install the Apache, MariaDB, PHP and other PHP extensions to your server. You can install all of them using the following command:

apt-get install apache2 mariadb-server php libapache2-mod-php php-mbstring php-xml php-json php-mysql php-curl php-intl php-gd php-mbstring texlive imagemagick unzip -y

Once all the packages are installed, you can proceed to create a database.

Step 3 – Create a Database

Next, login to the MariaDB shell with the following command:

mysql

Once you are login, create a database and user for MediaWiki with the following command:

CREATE DATABASE mediawiki;
GRANT ALL PRIVILEGES ON mediawiki.* TO 'wikiuser'@'localhost' IDENTIFIED BY 'password';

Next, flush the privileges and exit from the MariaDB with the following command:

flush privileges;
exit;

At this point, your MariaDB database is created.

Step 4 – Download MediaWiki

Next, you will need to download the latest version of MediaWiki to the Apache web root directory. You can download it with the following command:

wget https://releases.wikimedia.org/mediawiki/1.35/mediawiki-1.35.2.zip

Once the download is completed, unzip the downloaded file with the following command:

unzip mediawiki-1.35.2.zip

Next, move the extracted directory to the Apache web root directory:

mv mediawiki-1.35.2 /var/www/html/mediawiki

Next, you will need to install Composer in your system. You can install it with the following command:

apt-get install composer -y

Once the Composer is installed, change the directory to the MediaWiki and install all PHP dependencies using the following command:

cd /var/www/html/mediawiki
composer install --no-dev

Once all the dependencies are installed, set proper permission to the MediaWiki with the following command:

chown -R www-data:www-data /var/www/html/mediawiki

Step 5 – Configure Apache for MediaWiki

Next, create an Apache virtual host configuration file for MediaWiki with the following command:

nano /etc/apache2/sites-available/mediawiki.conf

Add the following lines:

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot /var/www/html/mediawiki/
    ServerName mediawiki.example.com

    <Directory /var/www/html/mediawiki/>
        Options FollowSymLinks
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

    ErrorLog /var/log/apache2/mediawiki_error
    CustomLog /var/log/apache2/mediawiki_access common
</VirtualHost>

Save and close the file then enable the virtual host file and restart the Apache service with the following command:

a2ensite mediawiki.conf
systemctl reload apache2

Step 6 – Access MediaWiki

Now, open your web browser and access the MediaWiki installation page using the URL http://mediawiki.example.com.

MediaWiki Setup Page

MediaWiki will now show its version. It will also say “LocalSettings.php not found”. We’ll be creating that file based on the next few steps. Get started by clicking on the link to “set up the wiki”.

MediaWiki Language Selection Page
On this page, you can choose the language for your wiki. Select your preferred options and click “Continue”. You should see the following page:

MediaWiki Terms Page
At this point, MediaWiki performs several checks before proceeding with the configuration.

If all is OK, the message “The environment has been checked. You can install MediaWiki” will appear. Press “Continue” to advance to the next step.

MediaWiki Database Page

Provide your database details and click on the Continue button. You should see the following page:
MediaWiki Database Account Page

Uncheck “Use the same account as for installation” and click on the Continue button. You should see the following page:

MediaWiki Site Information Page

Provide your sitename, admin username, password and click on the Continue button. You should see the following page:
MediaWiki Download LocalSettings Page

Now, download the “LocalSettings.php” file to your system and copy it to the /var/www/html/mediawiki directory over the SSH. Then, set the correct ownership using the following command:

chown www-data:www-data /var/www/html/mediawiki/LocalSettings.php

Once you have completed this last step, back in your browser click the “enter your wiki” link. You will be redirected to the MediaWiki dashboard:
MediaWiki Dashboard Page

More Resources

The default main page of your wiki includes several useful links where you can learn more about all the features included with MediaWiki and the ways to use it.

An excellent starting point is the MediaWiki User’s Guide.

Thank you for following along this how-to, please check out our other related articles at the bottom of the page.

Get A Free To Use Cloud VPS

Free Tier Includes:
G3.2GB Cloud VPS Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


Looking for a Hosting Solution?

We Provide Cloud, Dedicated, & Colocation.

  • Seven Global Data Center Locations.
  • Flexible Private, Public, & Hybrid Hosting.
  • 24x7x365 Security, Support, & Monitoring.
Contact Us Now! Med Tech Award FTC
SOC Audit HIPAA Audit HITECH Audit

Recent Posts

Get started with 12 months of free cloud VPS hosting

Free Tier includes:
G3.2GB Cloud VPS Server Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year

New York, NY

100 Delawanna Ave, Suite 1

Clifton, NJ 07014

United States

San Francisco, CA

2820 Northwestern Pkwy,

Santa Clara, CA 95051

United States

Dallas, TX

2323 Bryan Street,

Dallas, Texas 75201

United States

Ashburn, VA

1807 Michael Faraday Ct,

Reston, VA 20190

United States

Orlando, FL

440 W Kennedy Blvd, Suite 3

Orlando, FL 32810

United States

Toronto, Canada

20 Pullman Ct, Scarborough,

Ontario M1X 1E4

Canada

London, UK

14 Liverpool Road, Slough,

Berkshire SL1 4QZ

United Kingdom

Resources