Basic MediaWiki Installation

From SaruWiki
Jump to navigation Jump to search

Preparations

In the following, we'll assume you already have the following packages installed and configured:

  • Apache2
  • MySQL-server
  • PHP5 (including php5-mysql)

Furthermore, you have the following credentials (name and password) or equivalent rights:

  • root (for installation and configuration of both MediaWiki and Apache2)
  • MySQL root (for MySQL database creation)

Update your APT sources, and run

apt-get install mediawiki

This installs all mediawiki files, including a default configuration. For your convenience, we've created a MediaWiki directory structure map. If you run Apache2 (as we recommend), then that is automatically configured (for the most part) as well. By the way, you can reconfigure MediaWiki with dpkg-reconfigure, but that will only ask you for which web servers you'd like to generate a default configuration (those web servers being apache, apache-ssl, apache2 and cherokee). To get Apache2 to serve the Wiki on the default alias /mediawiki, edit /etc/mediawiki/apache.conf. Uncomment the alias line, so that the top of the file looks like this:

# Uncomment this to add an alias.
# This does not work properly with virtual hosts..
Alias /mediawiki /var/lib/mediawiki

Then restart or reload Apache2:

invoke-rc.d apache2 reload

What does the config file mean with "does not work properly", you might ask? Well, the Mediawiki config file is placed in /etc/apache2/conf.d using a symlink, so that it is loaded "generally", and not included within any Virtual Host. The consequence is, that the Mediawiki configuration, including the alias, works in every Virtual Host that you'll configure. If this is not what you want, despair not and just follow these directions. Further on down we will describe how you can fix this potentially unwanted behaviour.

Now the MediaWiki instance is being served on your webserver; you should be able to visit http://yourserver.lan/mediawiki, and see the friendly MediaWiki sunflower, and a link to "Please set up the wiki first".

Configuring the Wiki instance

Clicking the "Please set up the wiki first" link will bring you to a single, long web page, that'll help you to actually create the Wiki instance. The first section contains the result of an environment check. It should end with the sentence "Environment checked. You can install MediaWiki.". If not, then you'll first have to fix whatever is holding back your MediaWiki installation.

The rest of the page is one long form. You'll have to provide all data to define your wiki. Questions are a.o. the following.

  • Site Config questions:
    • The Wiki name: Must not be blank or "MediaWiki" and may not contain "#". Preferably a short word without punctuation, i.e. "SaruWiki". Will appear as the namespace name for "meta" pages, and throughout the interface.
    • Contact e-mail: Displayed to users in some error messages, used as the return address for password reminders, and used as the default sender address of e-mail notifications.
    • Language: determines the wiki interface localization. We only have experience with "en - English" but the pulldown list reveals an impressive list of languages, from "nl - Nederlands" to "jut - Jysk" and from "ak - Akan" to "yo - Yorùbá".
    • the Copyright/license: you can have your Wiki display the GNU Free Documentation License, a Creative Commons license (that you'll have to select in a page under a hyperlink), or no license metadata at all. Think careful what you want with the materials that you and others create in your Wiki instance!
    • an Admin username and password: the proposed default is WikiSysop. Provide a strong password!
  • Email notification and authentication setup:
    • Email address authentication: if this is enabled, then users have to confirm their e-mail address using a magic link sent to them whenever they set or change it, and only authenticated e-mail addresses can receive mails from other users and/or change notification mails. Setting this option is recommended for public wikis because of potential abuse of the e-mail features just above this particular question.
  • Database options:
    • Database type: You can choose from a list of one, being MySQL :-).
    • Database host: can be localhost, if you've installed MySQL on this same machine, but can also be an IP address or a DNS name to a remote MySQL server
    • Database name: Here you choose under what name the database will be created in the MySQL server. The default is wikidb.
    • Database user: With the MySQL root privileges, we can have the MediaWiki configuration script create a new user within the new database, that has the necessary privileges to enter data in, and read data from, the MySQL database. The proposed name is wikiuser, and you'll have to provide a strong (!) password.
    • Superuser account: check the box to signal that you have a root account for the MySQL server, fill in the name (presumably 'root) and the password, so that the configuration script gets the authority to create the wikidb database and all necessary users, tables et cetera.
  • There are some MySQL specific options, most importantly:
    • Database table prefix: If you need to share one database between multiple wikis, or between MediaWiki and another web application, you may choose to add a prefix to all the table names to avoid conflicts. Avoid exotic characters; something like mw_ is good. However, if you plan to have only a single wiki, then this box can remain empty.
    • Storage Engine: choose between InnoDB and MyISAM. InnoDB is the default.
    • Database character set: "Backwards-compatible UTF-8" is the default choice

Having provided all the above info, you can click the bottom button optimistically labeled "Install MediaWiki!". If you left something important empty (e.g. the Wiki name cannot be blank) or gave inconsistant information (two different passwords for "wikiuser"), you're thrown back to the same page with an urgent red box at the top:
"Something's not quite right yet; make sure everything below is filled out correctly.".

However, when you've gotten it right, you'll see a result page, ending with Installation successful!

Finishing up the configuration

The above procedure has resulted in a new configuration file /var/lib/mediawiki/config/LocalSettings.php (owner: www-data:www-data), and in a database in your MySQL server named as you've indicated (presumably wikidb, right?). As the result page indicated, you'll have to now move the LocalSettings.php file to /etc/mediawiki, and set the permissions so that no-one can mess with that file:

cd /etc/mediawiki
mv /var/lib/mediawiki/config/LocalSettings.php . 
chmod 444 LocalSettings.php

If you now follow the link to http://yourserver.lan/mediawiki, you'll find yourself on the default start page of your new Wiki instance. You can immediately start using your Wiki, or you can add things like extensions.

Furthermore, should you ever need to run a maintenance script (contained in /var/lib/mediawiki/maintenance) you will want to provide those scripts with the database admin password. To this end, copy /usr/share/doc/mediawiki/examples/AdminSettings.sample to /etc/mediawiki/AdminSettings.php. Then, secure this file by chmodding it to 600 and chowning it to root:root. Finally, put in the MySQL root database user, something like

$wgDBadminuser      = 'root';
$wgDBadminpassword  = 'waYacUbaT2uW';

Of course, you need to put in your MySQL root user data. Furthermore, you'll probably understand that you need to be really careful with this data.

The configuration files for MediaWiki under Debian

When you've installed MediaWiki under Debian, the configuration of it is contained in the following files and databases:

  • /etc/mediawiki/LocalSettings.php - exists only after configuration is completed; contains the settings PHP needs to run all its PHP scripts according to your wishes for your wiki.
  • /etc/mediawiki/AdminSettings.php - optional configuration to facilitate using maintenance scripts.
  • /etc/mediawiki/apache.conf - contains the Apache2 configuration lines.
  • MySQL database wikidb - exists only after configuration is completed; contains the wiki content itself.