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;

Install Mediawiki

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:


ServerAdmin [email protected]
DocumentRoot /var/www/html/mediawiki/
ServerName example.com

Options +FollowSymLinks
AllowOverride All

ErrorLog /var/log/apache2/media-error_log
CustomLog /var/log/apache2/media-access_log common

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

Access Mediawiki

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

How to install MediaWiki on Ubuntu 18.04 LTS_第1张图片

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

How to install MediaWiki on Ubuntu 18.04 LTS_第2张图片

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

How to install MediaWiki on Ubuntu 18.04 LTS_第3张图片

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

How to install MediaWiki on Ubuntu 18.04 LTS_第4张图片

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

How to install MediaWiki on Ubuntu 18.04 LTS_第5张图片

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

How to install MediaWiki on Ubuntu 18.04 LTS_第6张图片

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

How to install MediaWiki on Ubuntu 18.04 LTS_第7张图片

How to install MediaWiki on Ubuntu 18.04 LTS_第8张图片

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

How to install MediaWiki on Ubuntu 18.04 LTS_第9张图片

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

How to install MediaWiki on Ubuntu 18.04 LTS_第10张图片

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

How to install MediaWiki on Ubuntu 18.04 LTS_第11张图片

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:

How to install MediaWiki on Ubuntu 18.04 LTS_第12张图片

Links

  • Ubuntu

  • MediaWiki