Check this Out!Visit our social network pages for recent updates!

Students question – How to Install MediaWiki on Ubuntu Servers?

Ubuntu 16.10 was recently released and if you are thinking about installing MediaWiki on it, continue below to learn how to.  The post below will describe the steps that one must take in order to install MediaWiki.

MediaWiki is an open source PHP-based application what was developed by the WikiMedia foundation. It once powered Wikipedia online. It’s a powerful application that individuals and businesses can use to create wiki contents online easily.

MediaWiki requires the LAMP stack to function. Just like any other PHP-based applications, without the LAMP stack, you won’t be able to run MediaWiki. LAMP is a acronym for Linux, Apache2, MySQL and PHP. WordPress, Joomla, Drupal all use this stack to function.

We’ve shown users and students how to install the LAMP stack. This post can be found at the link below:

https://websiteforstudents.com/question/install-lamp-stack-ubuntu-server/

The post above shows you the steps to install the LAMP stack, however, Ubuntu comes with MediaWiki installer package in its repositories. The installer installs all that are required software for MediaWiki to function. So, following the steps be might be the easiest way to install MediaWiki.

Step 1: Update your server

To install packages on Ubuntu, your first task should be updating the server. You may run into issues sometimes if you don’t run the commands to update the Ubuntu before attempting to install packages.

To update Ubuntu, run the commands below:

sudo apt-get update

Step 2: Install MySQL database server

MySQL is part of the LAMP stack. To install MySQL server, run the commands below.

sudo apt-get install mysql-server mysql-common mysql-client

When you run the above commands, Ubuntu package installer displays the packages that will be installed on your system. To install them, type Y for Yes and continue.

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libaio1 libevent-core-2.0-5 libhtml-template-perl mysql-client-5.7
mysql-client-core-5.7 mysql-server-5.7 mysql-server-core-5.7
Suggested packages:
libipc-sharedcache-perl mailx tinyca
The following NEW packages will be installed:
libaio1 libevent-core-2.0-5 libhtml-template-perl mysql-client
mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server
mysql-server-5.7 mysql-server-core-5.7
0 upgraded, 10 newly installed, 0 to remove and 31 not upgraded.
Need to get 19.7 MB of archives.
After this operation, 170 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y

During the installation, you’ll be prompted to create a password for the root user for MySQL server. Type and confirm a password to continue.

Ubuntu MySQL password prompt screen

After installing MySQL continue below to create a database for MediaWiki and a user.

Step 3: Create MediaWiki database and user account

When you’re done installing MySQL, run the commands below to sign into the database server

mysql -u root -p

Then type the password you created above. When you’re logged in, run the SQL commands below to create a new database called mediawikidb

CREATE DATABASE mediawikidb;

Next, run the SQL commands below to create a database user named wikiuser with password and grant the user all rights to the database.

GRANT ALL ON mediawikidb.* to 'wikiuser'@'localhost' IDENTIFIED BY 'type_new_password_here';

Save your work and exit.

FLUSH PRIVILEGES;

Step 4: Installing MediaWiki on Ubuntu 16.10

Finally, run the commands below to install MediaWiki packages. You can choose to install Apache2, PHP and other packages individually. However, installing MediaWiki package will also install Apache2, PHP and all other packages that are required for MediaWiki to function.

To install MediaWiki, run the commands below.

sudo apt-get install mediawiki

When the commands above is executed, Ubuntu package installer shows you all the packages that will be installed. Review and type Y to continue.

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
apache2 apache2-bin apache2-data apache2-utils javascript-common
libapache2-mod-php7.0 libapr1 libaprutil1 libaprutil1-dbd-sqlite3
libaprutil1-ldap libjs-jquery liblua5.1-0 mediawiki-classes php php-common
php-curl php-intl php-mbstring php-mysql php-wikidiff2 php-xml php7.0
php7.0-cli php7.0-common php7.0-curl php7.0-intl php7.0-json php7.0-mbstring
php7.0-mysql php7.0-opcache php7.0-readline php7.0-xml
Suggested packages:
apache2-doc apache2-suexec-pristine | apache2-suexec-custom php-pear
memcached clamav php-apcu hhvm
The following NEW packages will be installed:
apache2 apache2-bin apache2-data apache2-utils javascript-common
libapache2-mod-php7.0 libapr1 libaprutil1 libaprutil1-dbd-sqlite3
libaprutil1-ldap libjs-jquery liblua5.1-0 mediawiki mediawiki-classes php
php-common php-curl php-intl php-mbstring php-mysql php-wikidiff2 php-xml
php7.0 php7.0-cli php7.0-common php7.0-curl php7.0-intl php7.0-json
php7.0-mbstring php7.0-mysql php7.0-opcache php7.0-readline php7.0-xml
0 upgraded, 33 newly installed, 0 to remove and 31 not upgraded.
Need to get 26.6 MB of archives.
After this operation, 143 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y

If you look at the list of packages being installed, you’ll find Apache2, PHP and others. That’s all you need to run MediaWiki. Other important PHP modules may be necessary to enable more advanced features.

After installing the packages above, restart Apache2 web server and browse to your server hostname or IP address to configure MediaWiki.

sudo systemctl restart apache2

Step 5: Downloading MediaWiki content

Next, run the commands below to download MediaWiki content. At the time of this post, the lastest stable version is 1.27.1.

cd /tmp && wget https://releases.wikimedia.org/mediawiki/1.27/mediawiki-1.27.1.tar.gz

Then run the commands below to extract the downloaded content.

tar -xvzf mediawiki-1*.tar.gz

Next, run the commands below to move the content to Apache2 default root directory.

sudo mv mediawiki-1.27.1/* /var/www/html

Change the directory permissions by running the commands below.

sudo chown -R www-data:www-data /var/www/html
sudo chmod -R 755 /var/www/html

Remove Apache2 default index.html file.

sudo rm /var/www/html/index.html

Restart Apache2 and browse to your server hostname or IP address.

http://192.168.1.1/

installing mediawiki on ubuntu

Click the link to setup MediaWiki up. Type the database information on this page and continue.

media wiki installing ubuntu

On this page, create an account to logon to MediaWiki portal.

mediawiki ubuntu 16.10

When you continue, you’ll be prompted to download MediaWiki local setting file. Download it. It’s very important that you save it.

mediawiki localsettings.php

After saving it, copy the LocalSettings.php file to the root directory of MediaWiki. /var/www/html/

sudo cp ~/Downloads/LocalSettings.php /var/www/html/

Once the LocalSettings.php file is in the root directory, you should be able to use MediaWiki.

mediawiki home page

Enjoy!

Leave a Reply