Installing Mediawiki

From Devpit

Jump to: navigation, search

Contents

Basic Installation

The easiest way to install is to just untar their source to a subdirectory of your document root, visit the page with a web browser, and let it tell you what to do. Installing it in a subdirectory is usually preferable so you can make nice URLs more easily (see below). The document root itself should be empty, except for the subdirectory (I use /mediawiki) and perhaps a few files normally found in a document root like robots.txt and .htaccess.

It is very helpful to follow these links before you install mediawiki:

Dependencies

  • Install Apache. Apache 1 works fine. I've heard Apache 2 works, but never tried it.
  • Install MySQL. Decide on a database name to dedicate to Mediawiki, but let Mediawiki's installer create it.
  • Install PHP and tell Apache to load mod_php. Enable execution for Mediawiki's directories if necessary. Also install the following PHP modules. This list is for FreeBSD's Ports Collection. If you install from another port collection or directly from PHP's distribution, some of these may be included in the core PHP package.
    • php5-gd
    • php5-mysql
    • php5-pcre
    • php5-session
    • php5-xml
    • php5-zlib
  • Restart Apache after installing the PHP modules. mod_php will not pick up new modules until you restart Apache!

Tips

  • To make upgrading easier:
    • Save your original LocalSettings.php immediately after installing, and keep your changes diff-friendly. When you upgrade, you must run the installation script again to upgrade your database and config file. This way, after upgrading, you can easily merge in the changes you made to LocalSettings.php.
    • From the mediawiki directory, consider doing this: mv images ../wiki-images; ln -s ../wiki-images images
    • Read http://www.mediawiki.org/wiki/Important_Release_Notes before every upgrade.
  • Never never never install mediawiki directly under the document root. Install it under $DOCROOT/mediawiki or something, then follow the directions below for pretty URLs. Some instructions on pretty URLs say to install directly under the document root. That is error-prone and complex.
  • Read all the sections below. Some have important considerations and good suggestions.

Robots.txt

Adding a robots.txt file is a very good idea. Good contents to start with is:

User-agent: *
Disallow: /mediawiki/
Disallow: /trap/
Disallow: /wiki/Special:Random
Disallow: /wiki/Special%3ARandom
Disallow: /wiki/Special:Search
Disallow: /wiki/Special%3ASearch
Crawl-delay: 1

The goal is to tell robots not to index your entire wiki, since robots will otherwise create a lot of unnecessary traffic. Also, indexing non-article pages is pretty pointless.

Also consider looking at Wikipedia's robots.txt for more ideas.

Making your logo an image in the wiki

Upload your logo as Wiki.png, then set this in Localsettings.php:

$wgLogo = "$wgUploadPath/b/bc/Wiki.png";

Controlling users

Preventing anonymous editing

Add this to LocalSettings.php (requires 1.5.1)

$wgGroupPermissions['*']['edit'] = false;

Preventing anonymous reading

Add this to LocalSettings.php (requires 1.5.1)

$wgGroupPermissions['*']['read'] = false;

Allowing only admins to create accounts

Add this to LocalSettings.php (requires 1.5.1)

$wgGroupPermissions['*']['createaccount'] = false;

Requiring approval of new accounts

This will allow people to create accounts, but the accounts will not let them do anything until you "approve" them by adding them to the "approved" group in the User Rights Management tool (Special:Userrights).

# Permission keys given to users in each group.
# All users are implicitly in the '*' group including anonymous visitors;
# logged-in users are all implicitly in the 'user' group. These will be
# combined with the permissions of all groups that a given user is listed
# in in the user_groups table.

# Implicit group for all visitors
$wgGroupPermissions['*']['createaccount'] = true;
$wgGroupPermissions['*']['read'] = true;
$wgGroupPermissions['*']['edit'] = false;
$wgGroupPermissions['*']['createpage'] = false;
$wgGroupPermissions['*']['createtalk'] = false;

# Implicit group for all logged-in accounts
$wgGroupPermissions['user']['move'] = false;
$wgGroupPermissions['user']['read'] = false;
$wgGroupPermissions['user']['edit'] = false;
$wgGroupPermissions['user']['createpage'] = false;
$wgGroupPermissions['user']['createtalk'] = false;
$wgGroupPermissions['user']['upload'] = false;
$wgGroupPermissions['user']['reupload'] = false;
$wgGroupPermissions['user']['reupload-shared'] = false;
$wgGroupPermissions['user']['minoredit'] = false;

# Approved accounts
$wgGroupPermissions['approved']['move'] = true;
$wgGroupPermissions['approved']['read'] = true;
$wgGroupPermissions['approved']['edit'] = true;
$wgGroupPermissions['approved']['createpage'] = true;
$wgGroupPermissions['approved']['createtalk'] = true;
$wgGroupPermissions['approved']['upload'] = true;
$wgGroupPermissions['approved']['reupload'] = true;
$wgGroupPermissions['approved']['reupload-shared'] = true;
$wgGroupPermissions['approved']['minoredit'] = true;

# Sysops
$wgGroupPermissions['sysop']['move'] = true;
$wgGroupPermissions['sysop']['read'] = true;
$wgGroupPermissions['sysop']['edit'] = true;
$wgGroupPermissions['sysop']['createpage'] = true;
$wgGroupPermissions['sysop']['createtalk'] = true;
$wgGroupPermissions['sysop']['upload'] = true;
$wgGroupPermissions['sysop']['reupload'] = true;
$wgGroupPermissions['sysop']['reupload-shared'] = true;
$wgGroupPermissions['sysop']['minoredit'] = true;

How to make nice wiki URLs

There are two ways to make nice URLs. One way puts documents under a virtual subdirectory, and the other way puts documents directly under your document-root. In both cases, install Mediawiki under /mediawiki in your document-root as described above. These instructions are for Apache 1.

Make URLs look like http://server-name/Main_Page

If you have a dedicated virtual-host for your wiki, and if you will never want to put any other content under that virtual-host, you can make your articles appear to be in the root directory with the instructions below. This is nicer, for example, if you want to set up a virtual-host called "wiki" under another domain name.

  • In the <VirtualHost> section of httpd.conf, add the following:
RewriteEngine on

# Don't rewrite requests for files that really exist or should return 404.
RewriteCond %{REQUEST_URI} !^/favicon.ico
RewriteCond %{REQUEST_URI} !^/robots.txt
RewriteCond %{REQUEST_URI} !^/mediawiki/

# Rewrite http://wiki/article -- this is the main rule
RewriteRule ^/(.*)$ /mediawiki/index.php/$1 [L,QSA]
  • Edit LocalSettings.php, and change these parameters:
$wgArticlePath = "/$1";

Make URLs look like http://server-name/wiki/Main_Page

Making documents appear in a virtual subdirectory is slightly easier, and is usually preferred so you can put other content on the same host:

  • In the <VirtualHost> section of httpd.conf, add the following:
Alias /wiki /http/devpit.org/mediawiki/index.php
  • Edit LocalSettings.php, and change these parameters:
$wgArticlePath = "/wiki/$1";

Quick Initial Configurations

Editor's note: Please don't describe every configuration knob you can think of here. Only knobs that are easy to change and likely to be changed on almost all installations should be described here.

Configuring the Sidebar

To configure the sidebar ("navigation" box), edit the article MediaWiki:Sidebar. This contains names of articles, each of which contains a name or a URL. The actual name or URL can't be directly in MediaWiki:Sidebar; those have to be in separate articles referenced by MediaWiki:Sidebar. For example, to add Special:Allpages:

  • Add allpages-url|allpages to MediaWiki:Sidebar.
  • Put "All pages" (the text for the link) in MediaWiki:Allpages. (In this case, it's already done because that string is used for other things as well. This probably means if you want to change it you should use a different article name.)
  • Put "Special:Allpages" (the article name) for the link in MediaWiki:Allpages-url.
Personal tools
projects