MediaWiki

Introduction
MediaWiki is a free software wiki package originally written for Wikipedia. It is now used by several other projects of the non-profit Wikimedia Foundation and by many other wikis, including this very website, the home of MediaWiki.

Links

 * MediaWiki official website
 * Technical Manual
 * Database Layout

System Requirements

 * Web server like Apache
 * PHP4 (4.3.3 or greater) or PHP5
 * MySQL or PostgreSQL

Installation

 * Download the free software MediaWiki version 1.6.7 or higher.
 * Extract the files. Example:

$ tar xvf mediawiki-1.6.7.tar.gz


 * Read the Install file under the extracted directory to know about the changes in the installation.
 * Rename it from "mediawiki-1.x.x" to something nice, like "wiki", since it'll be in your URL. Example:

$ mv mediawiki-1.6.7 /opt/www/wiki


 * You'll need to temporarily make the 'config' subdirectory writable by the web server. Example:

$ chmod a+w /opt/www/wiki/config/

Database creation
$ mysql -u root -p mysql>create database wikidb; mysql>GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON wikidb.* TO 'wikiuser'@'localhost' IDENTIFIED BY 'password'; mysql>FLUSH PRIVILEGES; mysql>quit
 * Create the database and user. For example:

Take note of the username, password, database name and hostname as you create the database.

Apache Configuration
Edit the file and insert the snippets:

DocumentRoot "/opt/www/wiki/" Alias /wiki/ "/opt/www/wiki/" Alias /wiki "/opt/www/wiki"
 * 1) wiki
 * 1) wiki

 Options FollowSymLinks AllowOverride None Order allow,deny Allow from all 


 * Now, you can test your wiki: http://localhost/wiki/

Start and Configuring MediaWiki
Now, MediaWiki is ready to run. Open your browser at http://localhost/wiki.


 * Enter the database information and password for the user WikiSysop. You will need it to manage the wiki later.
 * Press the button Install and wait until the process is concluded.
 * For security reasons change the permissions of the directory config and rename it:

$ chmod a-rw /opt/www/wiki/config/ $ mv config config790936


 * Move the file into the parent directory . You should configure this file properly, if you do not want users changing the pages without login. See the section Changing user rights.

Upgrade
More information about upgrading your version of MediaWiki is here.

As far as I know it is not possible to update a website without the operational system console (shell or cmd for example). The upgrade task will process all the old tables, It will change tables or columns as needed.

To upgrade your version of MediaWiki follow the instructions below:


 * Make a backup of all the files and database of the current version.


 * Create a new directory and put a new version of MediaWiki.


 * Copy the of your current version of MediaWiki to the root path of the new directory created above.


 * Copy the file to.


 * Edit this file and change the values of $wgDBadminuser and $wgDBadminpassword variables to identify a SQL user who will be enabled to all database maintenance scripts.


 * Execute the commands:

$ cd /maintenance $ php update.php --aconf ../AdminSettings.php


 * Check for errors and correct them.


 * Remove the files and.


 * Copy the directories and  of your current version of MediaWiki to the root path of the new directory. The extension must be compatible with the new version of MediaWiki.


 * Open your browser and navigate to  http://www.your-site.com/wiki/config/  and follow the instructions in order to create the file.


 * Move the file to the root directory.


 * Make the directory inaccessible.


 * Configure the settings of your new version of MediaWiki like the old version, i.e., compare and copy some parts of the old file to the new one.

Customizing the MediaWiki
Many customization described here are based on the Configuration Settings page of the MediaWiki Manual.

Logo
The $wgLogo variable specifies which graphical logo is displayed in the top left corner of all mediawiki pages. The default logo is located on. Replace this file and add the following two lines to :

$wgStylePath  = "$wgScriptPath/skins/"; $wgLogo       = "{$wgStylePath}/common/images/wiki.png";
 * 1) Logo Settings #

Customize the sidebar
As Administrator edit the page MediaWiki:Sidebar. Then try to find out more details about this task at MediaWiki Help Content.

Background image
To change the background image, modify the file or the file of your selected skin.

Image uploads
In order to allow users to upload files to the MediaWiki system, you have to enable that feature and configure some variables. Edit the file and set the $wgEnableUploads variable to true.

$wgEnableUploads      = true; $wgUseImageResize 	= false; $wgUploadPath      	= "$wgScriptPath/images"; $wgFileExtensions 		= array('png','jpg','jpeg','gif');
 * 1) To enable image uploads, make sure the 'images' directory
 * 2) is writable, then set this to true:
 * 1) List of accepted extensions
 * 1) $wgUseImageMagick = true;
 * 2) $wgImageMagickConvertCommand = "/usr/bin/convert";
 * 1) If you want to use image uploads under safe mode,
 * 2) create the directories images/archive, images/thumb and
 * 3) images/temp, and make them all writable. Then uncomment
 * 4) this, if it's not already uncommented:
 * 5) $wgHashedUploadDirectory = false;

How do I change the footer?
More information about this topic here.

To add or remove items from the footer on your MediaWiki page, you must edit the skin.

For example: if you go in to (located by default in the skins folder) you will find the following code:

$footerlinks = array(  'lastmod', 'viewcount', 'numberofwatchingusers', 'credits', 'copyright',   'privacy', 'about', 'disclaimer', 'tagline',  );

In the above you can simply add and remove items from the footer that you wish to appear in your footer. Remember the changes may not appear immediately because of MediaWiki caches.

You can also customize the individual items by modifying certain pages or parameters:
 * lastmod - last modification of the page.
 * viewcount - view counter of the page.
 * numberofwatchingusers - number of watching users of the page.
 * copyright - copyright of your website.
 * privacy - privacy policy of the website.
 * about - text that tells about your website.
 * disclaimer - disclaimers.
 * tagline - not currently used in the footer.

How can I edit / remove the Powered by MediaWiki image in the footer?
You can hide the Powered by MediaWiki image by adding the following to your wiki's MediaWiki:Common.css:


 * 1) f-poweredbyico { display: none; }

Changing user rights
More information about this topic here

Edit the file and add/change as follows:

Insert the following commands after the line *BELOW*: require_once( "includes/DefaultSettings.php" );

$wgGroupPermissions['*']['edit'] = false;
 * 1) Specify who can edit: true means only logged in users may edit pages

$wgWhitelistRead = array( "Main Page", "Special:Userlogin", "-", "MediaWiki:Monobook.css" );
 * 1) Pages anonymous (not-logged-in) users may see

$wgGroupPermissions['*']['createaccount'] = false;
 * 1) Specify who may create new accounts: 0 means no, 1 means yes

$wgShowIPinHeader = false; # For non-logged in users

$wgEnableUploads = true; # enable image uploads

Extensions
Extensions are compilations of PHP code that add new features or enhance functionality of the main MediaWiki core. Extensions are one of the main advantages of MediaWiki. They give wiki administrators and wiki end-users the ability to adapt MediaWiki to their requirements. They can be found below:
 * Extensions by category
 * Extensions in Wikimedia version control
 * Extension Matrix.

More information about Extensions.

MetaTags Keywords and Description
To add the metatags keywords and description to each wiki page you have to install the following extensions:
 * MetaKeywordsTag
 * MetaDescriptionTag

Copy the files to the directory and add the following code to the end of the file :

require_once( "$IP/extensions/MetaTags/MetaDescriptionTag.php" ); require_once( "$IP/extensions/MetaTags/MetaKeywordsTag.php" );
 * 1) Extensions: MetaKeywordsTag and MetaDescriptionTag
 * 1) Extensions: MetaKeywordsTag and MetaDescriptionTag

To use them use the new wiki tags metadesc and keywords. Add them to the beginning or end of your wiki page. Example:

enter here the description for this wiki page 

Additionally you can avoid the default keywords metatag generated automatically by MediaWiki if you comment the line below of the file : $this->addMeta( 'keywords', preg_replace(array_keys($strip), array_values($strip),implode( ",", $this->mKeywords ) ) );

It will avoid duplicated keywords metatags in the wiki pages.

Delete a Wiki page permanently
To delete a wiki page from the database without leaving trace you have to install the extension DeletePagePermanently

After the installation, a new tab called delete permanently will be available for the groups with permission to use this feature.

User Merge and Delete
You have to install the extension User Merge and Delete in order to merge references from one user to another user in the Wiki database. It will also delete old users.

Converting documents to mediawiki markup

 * Convert HTML to Wiki markup: Diberri's html2wiki
 * Convert MS-Word document to Wiki markup: Extension Word2MediaWikiPlus
 * The OpenOffice.org office suite also does a good job of reading MS Word and a usable job of exporting as MediaWiki wikitext.

More solutions are described below:
 * Converting documents to mediawiki markup
 * MediaWiki Manual - Importing external content

Creating pretty tables

 * Edit the file if you use the monobook skin as default for you wiki. Otherwise edit the corresponding css file.
 * Add the following information:

/* wikitable class for skinning normal tables */

table.wikitable { margin: 1em 1em 1em 0; background: #f9f9f9; border: 1px #aaaaaa solid; border-collapse: collapse; }

table.wikitable th, table.wikitable td { border: 1px #aaaaaa solid; padding: 0.2em; }

table.wikitable th { background: #f2f2f2; text-align: center; }

table.wikitable caption { margin-left: inherit; margin-right: inherit; }

Searching text with 2 or 3 letters
The default search function in MediaWiki is restricted to words > 3 characters. In order to change this behavior certify that the following entries are defined in the file : [mysqld] ft_min_word_len=3 [myisamchk] ft_min_word_len=3

If not, add them and restart the server. Furthermore, you have to check whether the MySQL index tables have no problems. Refer to the pages "Using myisamchk for Crash Recovery" for more information how it works. It is better to stop the server and execute the following commands:

$ cd / $ myisamchk -e --update-state *.MYI


 *  is the data tables directory of mysql, normally found in /var/lib/mysql.
 *  is the database name.

Take note of the name of the tables where problems occurred like: "Client is using or hasn't close the table properly" and "check data record references index: 1".

Then, backup the files first and apply the recovery on the tables:

$ myisamchk -r -q  $ myisamchk -r -q user_newtalk $ myisamchk -r -q searchindex

Note: You don't have to write the extension of the table used in .

Now you can restart the server and shall be able to search for strings that contains 3 characters.

Debug Mode
By adding the following line to your file, you will be able to log everything that WikiMedia does: $wgDebugLogFile = "$IP/log4me.txt";

Reduce the Wiki database size
Sometimes your Wiki database increase enormously the size. The best way to reduce the size is to delete old revisions (history, archive) from the database.

Run the MySQL console or phpMyAdmin and execute the script below created by Robert Glover and posted at https://bugzilla.wikimedia.org/show_bug.cgi?id=4748

DROP TABLE IF EXISTS temp_newest_rev; CREATE TABLE temp_newest_rev AS (SELECT MAX(rev_id) AS rev_id FROM revision GROUP BY rev_page, rev_user); DROP TABLE IF EXISTS temp_newest_text; CREATE TABLE temp_newest_text AS (SELECT MAX(rev_text_id) AS rev_text_id FROM revision GROUP BY rev_page, rev_user); DELETE FROM text WHERE old_id NOT IN (SELECT rev_text_id FROM temp_newest_text); DELETE FROM revision WHERE rev_id NOT IN (SELECT rev_id FROM temp_newest_rev); DELETE FROM recentchanges WHERE rc_id NOT IN (SELECT rev_id FROM temp_newest_rev); DROP TABLE temp_newest_rev; DROP TABLE temp_newest_text;

After this you should optimze your tables, executing the following SQL command: OPTIMIZE TABLE `revision`, `text` , `recentchanges`

Installation, configuration and customization of MediaWiki. Tips and tricks are described here.

