Learn how to install MediaWiki on Linux Ubuntu 22.04 LTS
Introduction
MediaWiki is an application for creating wikis that was written in PHP and was created by the Wikimedia Foundation. Its most well-known project is the online encyclopedia, Wikipedia. Wikis are websites that are designed to allow their users to contribute and edit content collaboratively. They can be used for many purposes, including as a knowledge repository, documentation library, community portal, or software documentation. These types of websites are particularly useful in scenarios where several individuals need to be able to quickly and easily create and modify pages.In this tutorial, I will show you how to install and configure MediaWiki on Linux Ubuntu 22.04 LTS, providing you with the foundation to launch your own wiki site.
Requirements
The following is a list of items needed to complete the installation successfully:
1) Linux Ubuntu 22.04 LTS or any newer version
2) An SSH client such as Putty or the MacOS terminal app
3) A public static IP address and a fully qualified domain name
4) A computer with atleast 4GB RAM, a dual core processor and atleast 50GB of free disk space
5) A stable internet connection
Overview
The following is an overview of the steps covered in this guide:
1) Update the system repository
2) Install Apache Web Server
3) Install PHP and needed extensions
4) Install MariaDB and create a database
5) Download and configure MediaWiki
6) Access the MediaWiki WebAdmin dashboard and complete the post installation setup
Step 1: Update the system repository
sudo su - sudo apt update -yWhen the update process completes, run the following command to restart the server:
sudo reboot
Step 2: Install Apache Web Server
sudo apt install apache2Once the installation completes, run the following commands to start and enable Apache:
systemctl enable --now apache2 systemctl start apache2
Step 3: Install PHP and needed extensions
Run the following commands to install PHP and extensions that are needed by the MediaWiki web application:
sudo apt install imagemagick php php-{fpm,intl,xml,curl,gd,mbstring,mysql,apcu,zip}
The command will download and install the latest php version that is available in the default ubuntu repository. For newer versions of PHP you may need to manually setup the PHP repo. When the PHP installation completes, open the php.ini configuration file using the command:
nano /etc/php/8.1/fpm/php.ini
Configure the following:
file_uploads = On allow_url_fopen = On upload_max_filesize = 512M post_max_size = 512M memory_limit = 512M max_execution_time = 600 date.timezone = Africa/Harare
Restart php and Apache by running the commands:
sudo systemctl restart php*-fpm.service
Step 4: Download and install MariaDB and create a database.
sudo apt install mariadb-serverWhen the installation completes, start the MariaDB secure installation script:
sudo mysql_secure_installationThe script is a mariadb configuration wizard designed to make the mysql installation more secure. You can provide the following responses to the script:
Enter current password for root: PRESS ENTER Change the root password [Y/n]? n Remove anonymous users? [Y/n] Y Disallow root login remotely [Y/n]? Y Remove test database and access to it [Y/n]? Y Reload privilege tables now [Y/n]? YRun the following command to allow MariaDB to start at system boot:
systemctl enable --now mariadbAccess the MySQL shell and create a new database for MediaWiki:
CREATE DATABASE wikidb; CREATE USER 'wikiuser'@'localhost' IDENTIFIED BY 'verystrongpassword'; GRANT ALL PRIVILEGES ON wikidb.* TO 'wikiuser' @'localhost' WITH GRANT OPTION FLUSH PRIVILEGES; EXIT;
Step 5: Download and configure MediaWiki
wget https://releases.wikimedia.org/mediawiki/1.41/mediawiki-1.41.1.zipWhen the download process completes run the following commands to unzip the mediawiki archive file and move it to the var/www/html directory:
sudo apt install unzip unzip mediawiki-1.41.1.zip rm -rf mediawiki-1.41.1.zip cd mediawiki-1.41.1/ mkdir /var/www/html/wiki cp -R * /var/ww/html/wikiChange the owner of the MediaWiki files to the www-data user and group:
sudo chown -R www-data:www-data /var/www/html/wiki
Step 6: Access the MediaWiki WebAdmin dashboard and complete the post installation setup.
The final step is accessing the MediaWiki WebAdmin dashboard and completing the post installation setup. Open a new browser window and navigate to http://example.com/wiki or http://server-ip/wiki. Click the “set up the wiki first” link, select your language, wiki language and click Continue. Enter the MySQL database name, username and password and click Continue. On the “Dashboard account for web access” section, ensure the “Use the same account as for installation” checkbox is checked and click Continue.
Enter the name of the wiki, specify the system administrator username, password, email and click Continue. Click Continue on the installation confirmation page and a LocalSettings.php file will be downloaded to your computer. Return to your SSH client and run the following command to create a new LocalSettings.php file:
nano /var/www/html/wiki/LocalSettings.phpCopy the contents of the LocalSettings.php file that was downloaded to your computer and paste the contents on the command line. Press CTRL + 0, hit Enter to confirm and press CTRL + X to exit the file. Run the following command to set the ownership of the LocalSettings.php file:
sudo chown www-data:www-data /var/www/html/wiki/LocalSettings.php
Conclusion
By following the steps outlined in this guide, you have successfully installed and configured MediaWiki on your Ubuntu 22.04 LTS server. This provides you with the foundation to launch your own collaborative wiki site, fostering the creation and sharing of knowledge among your users. Remember to replace example.com with your actual domain name throughout the process for a functional wiki.
This guide covered essential aspects of setting up MediaWiki, including:
1. Installing the necessary software dependencies like Apache, PHP, and MariaDB.
2. Securing the MariaDB installation.
3. Creating a database and user specifically for MediaWiki.
4. Downloading and configuring MediaWiki files.
5. Completing the MediaWiki web-based installation process.
Congratulations! You are now well on your way to building a vibrant online community through your very own wiki platform.