How to install MediaWiki on Ubuntu 18.04 LTS

Mediawiki is a free and open source wiki software that allows you to create your own wiki site. It is written in PHP and uses MySQL/MariaDB database backend. Mediawiki comes with lots of features including, Multilanguage support, User Management, Content management and sharing, Editing, Formatting, Referencing and much more.

In this tutorial, we will learn how to install Mediawiki with Apache web server on Ubuntu 18.04 server.

Requirements

  • A server running Ubuntu 18.04.
  • A non-root user with sudo privileges.

Install LAMP Server

First, install Apache and MariaDB server using the following command:

sudo apt-get install apache2 mariadb-server -y

Once both packages are installed, you will need to add Ondrej PHP repository to your system. You can add it with the following command:

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php -y

Once the repository is installed, update the repository and install PHP along with all the required PHP libraries:

sudo apt-get update -y
sudo apt-get install php7.2 libapache2-mod-php7.2 php7.2-common php7.2-mbstring php7.2-xmlrpc php7.2-soap php7.2-gd php7.2-xml php7.2-intl php7.2-mysql php7.2-cli php7.2-mcrypt php7.2-zip php7.2-curl -y

Once all the packages are installed, open php.ini file with the following command:

sudo nano /etc/php/7.2/apache2/php.ini

Make the following changes:

memory_limit = 256M
upload_max_filesize = 100M
max_execution_time = 360
date.timezone = Asia/Kolkata

Save and close the file, then start Apache and MariaDB service and enable them to start on boot time:

sudo systemctl start apache2
sudo systemctl enable apache2
sudo systemctl start mysql
sudo systemctl enable mysql

Configure MariaDB

First, secure MariaDB installation with the following command:

sudo mysql_secure_installation

Answer all the questions as shown below:

 Enter current password for root (enter for none):
 Set 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]: Y

Once the MariaDB is secured, log in to MariaDB shell:

mysql -u root -p

Enter your root password when prompt, then create a database and user for Mediawiki:

MariaDB [(none)]>CREATE DATABASE mediadb;
MariaDB [(none)]>CREATE USER ‘media’@’localhost’ IDENTIFIED BY ‘password’;

Next, grant all the privileges to the mediadb with the following command:

MariaDB [(none)]>GRANT ALL ON mediadb.* TO ‘media’@’localhost’ IDENTIFIED BY ‘password’ WITH GRANT OPTION;

Next, flush the privileges and exit from the MariaDB shell:

MariaDB [(none)]>FLUSH PRIVILEGES;
MariaDB [(none)]>EXIT;

First, download the latest version of Mediawiki from their official website:

wget https://releases.wikimedia.org/mediawiki/1.31/mediawiki-1.31.0.tar.gz

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

tar -xvzf mediawiki-1.31.0.tar.gz

Next, copy the extracted directory to the Apache root directory and give proper permissions:

sudo cp -r mediawiki-1.31.0 /var/www/html/mediawiki
sudo chown -R www-data:www-data /var/www/html/mediawiki
sudo chmod -R 777 /var/www/html/mediawiki

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

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

add the following lines:

<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/mediawiki/
ServerName example.com
<Directory /var/www/html/mediawiki/>
Options +FollowSymLinks
AllowOverride All
</Directory>
ErrorLog /var/log/apache2/media-error_log
CustomLog /var/log/apache2/media-access_log common
</VirtualHost>

Save the file, then enable virtual host file and Apache rewrite module with the following command:

sudo a2ensite mediawiki.conf
sudo a2enmod rewrite

Finally, restart Apache web server to make the changes:

sudo systemctl restart apache2

Now, open your web browser and type the URL http://example.com. You will be redirected to the following page:

MediaWiki Installer

Now, click on the set up the wiki button. You should see the following page:

Choose language

Here, choose your wiki language and click on the Continue button. You should see the following page:

Installation environmnet check

Now, click on the Continue button. You should see the following page:

Database details

Now, provide your database details and click on the Continue button. You should see the following page:

Select database type

Now, select storage engine and click on the Continue button. You should see the following page:

Set a site name, username and password

Now, provide your wiki site name, username and password. Then, click on the Continue button. You should see the following page:

MediaWiki Settings

MediaWiki Settings - page 2

Now, mark all your required settings and click on the Continue button. You should see the following page:

Start MediaWiki installation

Now, click on Continue button to start the installation. Once the installation is completed. You should see the following page:

Installation finished

Now, click on the Continue button. You should see the following page:

DownloadlocalSettings.php

Here, you need to download the LocalSettings.php file and put it on MediaWiki root directory.

Now, open your web browser and type the URL http://example.com. You should see your MediaWiki site in the following image:

MediaWiki start page

Hitesh Jethva

About Hitesh Jethva

Over 8 years of experience as a Linux system administrator. My skills include a depth knowledge of Redhat/Centos, Ubuntu Nginx and Apache, Mysql, Subversion, Linux, Ubuntu, web hosting, web server, Squid proxy, NFS, FTP, DNS, Samba, LDAP, OpenVPN, Haproxy, Amazon web services, WHMCS, OpenStack Cloud, Postfix Mail Server, Security etc.

Share this page:

how to install mediawiki on ubuntu 18 04 lts 12
how to install mediawiki on ubuntu 18 04 lts 13
how to install mediawiki on ubuntu 18 04 lts 14
how to install mediawiki on ubuntu 18 04 lts 15

نوشته های مشابه