MediaWiki is a PHP wiki package, originally intended for use on Wikipedia, which allows anyone to create their own personal wiki site. It is used by a majority of the wikis on the Internet. More information about MediaWiki can be found on its homepage.
This tutorial goes through how to set up MediaWiki on a Ubuntu 14.04 Droplet.
After you have installed the LAMP stack, we will first need to install a few additional PHP 5 modules. All four are optional, but the first two in particular (Intl and GD) are recommended.
The first one we will be installing is the Intl extension, for internationalization support:
sudo apt-get install php5-intl
Secondly, we will install GD for image thumbnailing:
sudo apt-get install php5-gd
You can install Tex Live for in-line display of mathematical formulae.
sudo apt-get install texlive
Finally, you can install XCache for added performance.
sudo apt-get install php5-xcache
After you’ve installed the modules you want, restart Apache.
sudo service apache2 restart
In this section we will download MediaWiki.
MediaWiki is available on the apt-get repository of Ubuntu, but it is out of date. Therefore, it is best to download MediaWiki from source.
curl -O http://releases.wikimedia.org/mediawiki/1.24/mediawiki-1.24.1.tar.gz
You can double check the latest version on this page. Copy the link from Download MediaWiki followed by a version number and use that instead of the link above.
After it has finished downloading, extract the package:
tar xvzf mediawiki-*.tar.gz
Next, we will move the MediaWiki directory to the document root:
sudo mv mediawiki-1.24.1/* /var/www/html
In this section we will set up a MySQL database. This is not strictly required to successfully install MediaWiki, as you can use a SQLite database as well. Despite this, it is definitely a recommended measure.
To create the database, we will first log in to MySQL:
mysql -u root -p
You will see your terminal prompt change to mysql>
.
We can now create the database. You can choose whatever database name you prefer, but the default name in MediaWiki’s configuration is my_wiki
.
CREATE DATABASE my_wiki;
You should see the output:
Query OK, 1 row affected (0.00 sec)
Next, we will create a database user for the MediaWiki installation:
GRANT INDEX, CREATE, SELECT, INSERT, UPDATE, DELETE, ALTER, LOCK TABLES ON my_wiki.* TO 'sammy'@'localhost' IDENTIFIED BY 'password';
Change the first highlighted variable to your chosen database name, the second variable to the username you want to use, and the last to a secure password. You should see the output:
Query OK, 0 rows affected (0.00 sec)
Next, we need to flush the MySQL privileges.
FLUSH PRIVILEGES;
The output should be:
Query OK, 0 rows affected (0.00 sec)
Last, we will need to exit the MySQL shell:
exit
The output should be:
Bye
In this section, we will set up MediaWiki so it is ready to use. Visit the homepage of your Droplet in your browser by pointing your browser to http://your_server_ip
. On this page, select set up the wiki.
On the first page, select a language and click Continue. The next page should show your environment and it should say in green: “The environment has been checked. You can install MediaWiki.” Click Continue.
You will now get to the page with MySQL settings. For the Database type select MySQL (or compatible). For the database host, use localhost, and for the database name, username, and password, use the values you chose before. The table prefix can be left empty. It will look like this:
After you have completed this step, you will need to complete the tutorial. In the screen after the MySQL settings, the values can be left at their defaults. In the next screen, you will need to fill in the details of your wiki, like its name. You can also create the admin user for the wiki on this page.
In all the other screens, most, if not all, of the settings can be left untouched. If you want a specific setting enabled for your wiki, you might need to change something on one of these screens. Particularly if you have installed XCache before, you will need to check that to enable it.
When you have completed these steps, you should arrive at this page:
A file called LocalSettings.php
should start downloading automatically. To successfully complete the installation, you need to move this file to the server, so make sure to download the file before closing the page.
You should now move it the file to /var/www/html
on the server. The easiest way to do this is to open the file on your own computer, copy the contents and paste them into the server. To do this, first open the file on the server:
nano /var/www/html/LocalSettings.php
Now, open the file on your computer in your text editor of choice and copy the contents into your SSH window. After you have saved the file, you can click enter your wiki and your wiki should be ready to use.
You have now installed your own MediaWiki installation which you can use for any purposes you like. You can now customize your installation using the links on the MediaWiki homepage or you can start adding pages.
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Great Article !!! Just be careful that LocalSettings.php should go to base of mediawiki folder.
I try to install math extension but if you use one-click-apps is some complicated configure textvc and folder permission. Can you create a tutorial to install Math extension correctly, please?
Dear Staff, I want install this extension https://www.mediawiki.org/wiki/Extension:PdfBook
Is possible to do from terminal without install vnc ? This are commands
apt-get install htmldoc nano /var/www/html/LocalSettings.php
and add this line at bottom of php file require_once “$IP/extensions/PdfBook/PdfBook.php”;
But then I need to place the file in a directory called PdfBook in your extensions/ folder. File is this I need to extract and then to copy in that folder - where ?
files are here https://github.com/OrganicDesign/extensions/tree/master/MediaWiki/PdfBook
Can you help me, please?
Using Xubuntu and VM Workstation, I was able to setup a cool Wiki for my work information. I added content (via the VM Console using Chromium and going to http://127.0.0.1) and was ready to publish it to the work LAN. I changed the IP setup so that it was now on the network LAN and not the VM LAN. I used Chrome and navigated to the assigned IP address and it fails. It says in the address bar “http://127.0.0.1/index.php/Main_Page” so it must be forwarding from it’s IP address of 172.18.30.30 to the local host of 127.0.0.1. Then the page says: This site can’t be reached 127.0.0.1 refused to connect. ERR_CONNECTION_REFUSED
If I am in the host and use Chromium, I type in the IP of 172.18.30.30 and it resolves to 127.0.0.1/index.php/Main_Page and it looks fine. It’s only when not on the host that it does not work.
I have tried scouring the net for a solution. It seems like a small problem, but I can not seem to find the correct solution. Do you have any suggestions?
While DigitalOcean’s MediaWiki image is a useful one (even while 1.24 is a legacy version, which is supported until November 2015, and MediaWiki 1.25 is now the ‘current version’), there might be some people who don’t want to re-install their server completely with a new image.
Also, 1.24.1 is not the most recent version of the 1.24 series anymore, 1.24.2 is now the newest version of the 1.24 series, and it includes multiple security fixes, so I recommend everyone to upgrade their 1.24.0 or 1.24.1 wiki to 1.24.2 (upgrading to 1.25 is recommended if possible - see https://www.mediawiki.org/wiki/Manual:Upgrading for instructions).
Digital Ocean now offers to deploy a droplet running MediaWiki. under Create Droplet>Applications>MediaWiki 1.24.2 on 14.04 After deployment SSH into the new droplet, configure username and password, and you’re good to go!
You will need to
sudo nano /var/www/html/LocalSettings.php
unless you are logged in as root, I think.Great article. It worked on my server. But then a read about another wiki called MDwiki and it got me interested. I managed to install MDwiki following this tutorial and after careful consideration and testing, I think that Media Wiki is better. Do you have any advice on what to use and what is better? Great work DO.