MediaWiki is a wiki application written in PHP that the Wikimedia Foundation developed to run several of their projects. The encyclopedia Wikipedia is the most popular of these projects.
A wiki is a type of website that allows its users to create and edit content in a collaborative manner. It can be used in several ways, including as a knowledge base, documentation library, community website, or company intranet.
These kinds of websites are especially useful in contexts where several people need to create and modify pages in a quick and easy way.
This guide will show you how to install and set up the application, giving you the basis to deploy your own wiki site.
We will use the domain name “example.com” in this guide. Replace it with the domain name or IP address you have configured on your server.
– An Ubuntu 14.04 server. You can run MediaWiki on a different flavor of GNU/Linux, but the steps outlined below could differ. If you do not have one, why not spin up a fast SSD Cloud server from Atlantic.Net.
Installing MediaWiki on Ubuntu 14.04
Before you begin, make sure your system is updated. From the command line, type:
sudo apt-get update sudo apt-get upgrade
Proceed to install the package:
sudo apt-get install mediawiki
The package management system will install all the dependencies required.
The MySQL database server is one of these dependencies. If MySQL is not already installed on your server, then the installer will prompt you for a password for the root MySQL user. Remember to choose a unique, secure password, different from the server user’s. Keep this password handy. You’ll need it again later during this installation.
There are also certain optional software packages used by MediaWiki that could be installed at this time. Although optional, they do provide useful features:
Imagemagick: a package used to create image thumbnails.
PHP5-intl: a PHP extension used for Unicode normalization.
PHP-apc: a package that provides cache features to PHP.
To install these optional packages, from the command line:
sudo apt-get install imagemagick php5-intl php-apc
Initial Configuration of MediaWiki
There are several configuration tasks to perform both on the server and with the guided web GUI before you will be able to use the wiki.
The first step is to configure the Apache web server.
Using your preferred text editor, open the
/etc/mediawiki/apache.conf file and uncomment the line beginning with Alias.
# Uncomment this to add an alias. # This does not work properly with virtual hosts.. Alias /mediawiki /var/lib/mediawiki # Uncomment the following line (instead of the one above) # to use the custom directory '/intranet' #Alias /intranet /var/lib/mediawiki <Directory /var/lib/mediawiki/> Options +FollowSymLinks AllowOverride All <IfVersion >= 2.3> Require all granted </IfVersion> <IfVersion < 2.3> order allow,deny allow from all </IfVersion> </Directory> [remaining configuration cut]
With this setting, the wiki will be accessible using a web browser and going to the
/mediawiki directory under your domain or IP address.
If you want to change the “/mediawiki” directory, simply replace the first “mediawiki” appearing in that line. Leave the second as it is because it is indicating the path where the files are located. There is a second Alias line included in the example above to demonstrate the configuration necessary to make your wiki accessible at www.example.com/intranet/.
The second step is to tell the Apache web server to use the file you just modified. Edit the Apache main configuration file
/etc/apache2/apache2.conf. At the end of the file, add the following line:
Finally, restart Apache to apply the changes. From the command line:
sudo apache2ctl restart
Using your web browser go to http://www.example.com/mediawiki.
If you changed the alias before, use the name you chose (from our example: http://www.example.com/intranet/).
MediaWiki will now show its version. It will also say “LocalSettings.php not found”. We’ll be creating that file based on the next few steps. Get started by clicking on the link to “set up the wiki”.
On this page, you can choose the language for your wiki. Select your preferred options and click “Continue”.
If you are curious about any of the parameters MediaWiki is asking you to select, you can click on the “help” link next to each input or selection field to open a short help window explaining its purpose.
At this point, MediaWiki performs several checks before proceeding with the configuration.
If all is OK, the message “The environment has been checked. You can install MediaWiki” will appear. Press “Continue” to advance to the next step.
The wiki installer will let you know if some of the optional software packages are missing, but it will let you continue anyway.
Connect to Database
In this step, you must provide the information to establish the connection with the database.
Enter the MySQL root password in “Database password” and click on “Continue”.
Creating the database and tables MediaWiki uses requires the MySQL root account (here’s where you’ll need that password from above). On the next screen, you will be able to tell MediaWiki to use another MySQL user for its normal operation.
Database Settings for MediaWiki
Uncheck “Use the same account as for installation” and enter a username and password for the MySQL account you will use to run MediaWiki. If the user does not exist yet, be sure to check the box for “Create the account if it does not already exist”.
On this screen, there are other settings related to the database. If you do not have special reasons for changing them, just leave the defaults options and click “Continue”.
Input the name for your wiki, and the administrator account settings.
Leave the “Ask me more questions” selected and click “Continue”.
Select the options that best fit your needs and press “Continue”. If you need help making your selection, remember to take a look at the “help” links that provide more information about each option.
Complete the Installation
MediaWiki now has all the configuration settings it needs to finish the installation process. If it does not detect any problems, it will proceed to commit these changes into a file called “LocalSettings.php”. You will then see a prompt to download the file to the system you are running your browser on.
The last step requires you to copy the downloaded file to the
/etc/mediawiki folder of your MediaWiki server.
You can transfer the file via something like scp or Filezilla, for example. You could also create the
LocalSettings.php file on the MediaWiki server with your preferred text editor and copy and paste the contents from the file you just downloaded.
Once you have added the configuration file into your server, you should change its owner/group and adjust its permissions. The Apache default user and group (www-data) should have ownership over this file. The permissions should let only that user read and write the file. From your server command line run:sudo chown www-data:www-data /etc/mediawiki/LocalSettings.phpsudo chmod 600 /etc/mediawiki/LocalSettings.php
Once you have completed this last step, back in your browser click the “enter your wiki” link. Or just access www.example.com/mediawiki/ (if you used a custom alias, then use that term instead, e.g. www.example.com/intranet/).
Now your wiki is ready to be used.
Changing the logo
Although instruction about further tuning your wiki exceeds the purpose of this guide, there is a quick customization you might want to make at this moment: change the logo that appears by default.
According to the MediaWiki documentation, a good logo size is 135x135px or 150x150px. Bigger sizes will get cut off.
Copy your logo image file to
/etc/mediawiki/LocalSettings.php with the text editor of your choice and edit the
$wgLogo line. Replace the last part of the path with the name of the file you copied. For example:
$wgLogo = "$wgStylePath/common/images/mylogo.png";
Save the change and access your wiki one more time. Your wiki will now display your custom logo.
The default main page of your wiki includes several useful links where you can learn more about all the features included with MediaWiki and the ways to use it.
An excellent starting point is the MediaWiki User’s Guide.
Thank you for following along this how-to, please check out our other related articles at the bottom of the page.