MediaWiki is a tool created to help you collect and organize knowledge and make it available to people inside and outside your organization. It is a very powerful, multilingual, extensible, customizable, reliable, and free of charge. Being a free to use and open source software gives you the flexibility to customize it to suit your needs.
In this guide we show you how to install and configure MediaWiki in Ubuntu 20.04 and Debian 10 system with Apache as the web server. The server used can be newly installed or a web server already used for hosting other applications.
Step 1: Update System
Update your Ubuntu or Debian system before you start installing MediaWiki dependencies and packages:
sudo apt update sudo apt -y full-upgrade
Reboot if the updates dictate that a system restart be perfomed.
Step 2: Install MariaDB database server
Next we install MariaDB database server:
sudo apt update sudo apt -y install mariadb-server
Run the commands below to secure your database server:
$ sudo mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. Set root password? [Y/n] y New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y ... Success! By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!
Change authentication plugin to force root user authentication:
$ sudo mysql -u root UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE User = 'root'; FLUSH PRIVILEGES; QUIT;
Confirm you can’t get to MySQL shell without password:
$ sudo mysql -u root ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) $ mysql -u root -p Enter password: <INPUT-PASSWORD> Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 47 Server version: 10.3.27-MariaDB-0+deb10u1 Debian 10 Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]>
Step 3: Install PHP on Debian | Ubuntu
Install PHP and all required extensions:
sudo apt install git php php-mysql php-xml php-mbstring php-apcu php-intl imagemagick inkscape php-gd php-cli php-curl php-bcmath libapache2-mod-php
Agree to start the installation:
0 upgraded, 194 newly installed, 0 to remove and 0 not upgraded. Need to get 98.9 MB of archives. After this operation, 393 MB of additional disk space will be used. Do you want to continue? [Y/n] y
Customize PHP parameters:
$ sudo vim /etc/php/7.*/apache2/php.ini
Set Maximum allowed size for uploaded files to at least 20M
upload_max_filesize = 20M
Set the maximum amount of memory a script may consume to 128M
memory_limit = 128M
Step 4: Install MediaWiki with on Ubuntu 20.04|Debian 10
Let’s now download the official MediaWiki tarball
cd /tmp/ wget https://releases.wikimedia.org/mediawiki/1.35/mediawiki-1.35.1.tar.gz
Extract the file downloaded:
tar -xvzf mediawiki-*.tar.gz rm mediawiki-*.tar.gz
Move the resulting folder to /var/www directory:
sudo mv mediawiki-* /var/www/html/mediawiki
Set correct directory permissions:
sudo chown -R www-data:www-data /var/www/html/mediawiki
Step 5: Configure MediaWiki on browser
Navigate your browser to http://serverip_or_hostname/mediawiki/mw-config/index.php to initiate MediaWiki configuration.
Choose language and select “Continue“
Proceed with the installation by clicking on “Continue“
Inout root database user credentials and database name to create.
Confirm database settings.
Make any modifications as desired.
Enter admin username, password and email address.
Press “Continue” to begin installation of MediaWiki.
The installer will generate a LocalSettings.php file which contains all your configuration.
Download the file and put it in the base of your wiki installation:
sudo mv LocalSettings.php /var/www/html/mediawiki/
Copying the file over ssh.
scp ~/Downloads/LocalSettings.php [email protected]:/var/www/html/mediawiki/LocalSettings.php
Proceed with the installation by pressing “Continue“
Navigate back to index page: http://serverip/mediawiki/index.php/
Login with the username and password for the admin user.
You should now have a working installation of MediaWiki on Ubuntu|Debian Linux system.