Difference between revisions of "MediaWiki"

 
(13 intermediate revisions by the same user not shown)
Line 2: Line 2:
  
 
=Installation=
 
=Installation=
 +
 +
==Mediawiki==
 +
 +
Get the latest mediawiki LTS version from the official website: https://www.mediawiki.org/wiki/MediaWiki
 +
 +
 +
 +
==Enable file upload==
 +
 +
It is important to enable File Upload so user can push images, videos and all kind of content.
 +
 +
Have a look to the official [https://www.mediawiki.org/wiki/Manual:Configuring_file_uploads MediaWiki File Upload manual].
 +
 +
 +
'''Configuration'''
 +
 +
Add / Edit the following code at the bottom of your LocalSettings.php:
 +
 +
<syntaxhighlight lang="php">
 +
$wgEnableUploads = true;                  # Enable uploads
 +
$wgUseImageMagick = false;                # Do NOT use ImageMagick to compute thumbnailed images.
 +
                                          # It is usually NOT available on shared hosting
 +
$wgImageMagickConvertCommand = "/usr/bin/convert";
 +
ini_set( 'post_max_size', '20M' );        # Max size of a HTTP POST operation (= sum of all files of the operation)
 +
ini_set( 'upload_max_filesize', '10M' );  # Max size of a single file
 +
 +
# List of allowed extensions to be uploaded
 +
$wgFileExtensions = array( 'png', 'gif', 'jpg', 'jpeg', 'doc', 'xls', 'mpp', 'pdf', 'ppt', 'tiff', 'bmp', 'docx', 'xlsx', 'pptx', 'ps', 'odt', 'ods', 'odp', 'odg');
 +
# To allow ZIP files upload
 +
$wgFileExtensions[] = 'zip';
 +
$wgTrustedMediaFormats[] = 'application/zip';
 +
</syntaxhighlight>
 +
 +
 +
 +
'''ERROR 500 fix'''
 +
 +
If you have problems to see the pictures, you need to adjust the <code>mediawiki/images/.htaccess</code> file to:
 +
 +
<syntaxhighlight lang="apache">
 +
<IfModule rewrite_module>
 +
RewriteEngine On
 +
RewriteCond %{QUERY_STRING} \.[^\\/:*?\x22<>|%]+(#|\?|$) [nocase]
 +
RewriteRule . - [forbidden]
 +
</IfModule>
 +
</syntaxhighlight>
 +
 +
 +
 +
==Extensions==
 +
 +
You can use Extensions to improve your wiki. You'll find below some recommendations.
 +
 +
You can always browse the official Extensions repository on https://www.mediawiki.org/wiki/Category:Extensions
 +
 +
 +
===SyntaxHighlight===
 +
 +
This is required to display source code with syntax support.
 +
 +
 +
'''Download'''
 +
 +
* [https://www.mediawiki.org/wiki/Extension:SyntaxHighlight SyntaxHighlight] (bundled by default since 1.21)
 +
 +
Please note that the SyntaxHighlight requires '''SyntaxHighlight_Geshi''':
 +
* Go to https://www.mediawiki.org/wiki/Special:ExtensionDistributor/SyntaxHighlight_GeSHi
 +
* Download the compress file for your wiki and place the file(s) in a directory called <code>SyntaxHighlight_GeSHi</code> in your <code>extensions/</code> folder.
 +
 +
 +
'''Configuration'''
 +
 +
Add the following code at the bottom of your LocalSettings.php:
 +
 +
<syntaxhighlight lang="php">
 +
# -------------------- LIST OF EXTENSIONS --------------------
 +
# MediaWiki 1.25+
 +
wfLoadExtension( 'SyntaxHighlight_GeSHi' );
 +
 +
# Old MediaWiki
 +
require_once "$IP/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php";
 +
 +
# -------------------- CONFIGURATION --------------------
 +
$wgSyntaxHighlightDefaultLang = "java";
 +
</syntaxhighlight>
 +
 +
 +
'''Install check-up'''
 +
 +
Navigate to '''Special:Version''' on your wiki to verify that the extension is successfully installed.
 +
 +
 +
'''Source / Help'''
 +
 +
[https://www.mediawiki.org/wiki/Extension:SyntaxHighlight official SyntaxHighlight help page]
 +
 +
 +
 +
===WikiEditor===
 +
 +
This WYSIWYG editor is much better than the default one!
 +
 +
 +
'''Download'''
 +
 +
* [https://www.mediawiki.org/wiki/Extension:WikiEditor WikiEditor] (bundled by default since 1.18)
 +
 +
 +
'''Configuration'''
 +
 +
Add the following code at the bottom of your LocalSettings.php:
 +
 +
<syntaxhighlight lang="php">
 +
# -------------------- LIST OF EXTENSIONS --------------------
 +
# MediaWiki 1.25+
 +
wfLoadExtension( 'WikiEditor' );
 +
 +
# Old MediaWiki
 +
require_once "$IP/extensions/WikiEditor/WikiEditor.php";
 +
 +
 +
# -------------------- WikiEditor extension --------------------
 +
# Enables use of WikiEditor by default but still allows users to disable it in preferences
 +
$wgDefaultUserOptions['usebetatoolbar'] = 1;
 +
 +
# Enables link and table wizards by default but still allows users to disable them in preferences
 +
$wgDefaultUserOptions['usebetatoolbar-cgd'] = 1;
 +
 +
# Displays the Preview and Changes tabs
 +
$wgDefaultUserOptions['wikieditor-preview'] = 1;
 +
 +
# Displays the Publish and Cancel buttons on the top right side
 +
$wgDefaultUserOptions['wikieditor-publish'] = 1;
 +
wfLoadExtension( 'SyntaxHighlight_GeSHi' );
 +
</syntaxhighlight>
 +
 +
 +
'''Install check-up'''
 +
 +
Navigate to '''Special:Version''' on your wiki to verify that the extension is successfully installed.
 +
 +
 +
'''Source / Help'''
 +
 +
[https://www.mediawiki.org/wiki/Extension:WikiEditor official WikiEditor help page]
 +
 +
 +
 +
===Cite===
 +
 +
This extension helps to display and manage sources + references + quotes. This is particularly useful for R&D and training pages.
 +
 +
 +
'''Download'''
 +
 +
* [https://www.mediawiki.org/wiki/Extension:Cite Cite] (bundled by default since 1.21)
 +
 +
 +
'''Configuration'''
 +
 +
Add the following code at the bottom of your LocalSettings.php:
 +
 +
<syntaxhighlight lang="php">
 +
# -------------------- LIST OF EXTENSIONS --------------------
 +
# MediaWiki 1.25+
 +
wfLoadExtension( 'Cite' );
 +
 +
# Old MediaWiki
 +
require_once "$IP/extensions/Cite/Cite.php";
 +
</syntaxhighlight>
 +
 +
 +
'''Source / Help'''
 +
 +
[https://www.mediawiki.org/wiki/Extension:Cite official Cite help page]
 +
 +
 +
===How to check the installation?===
 +
 +
Navigate to '''Special:Version''' on your wiki to verify that the extension is successfully installed and enabled.
 +
 +
 +
===How to know what are the current installed extensions?===
 +
* Go to ''Special:Version''
 +
 +
 +
 +
 +
 +
 +
=Configuration=
 +
 +
==Create users and grants rights==
 +
 +
# As the ''Admin'' user go to '''Special page''' > '''Create account'''
 +
# Set the user rights: go to http://wikiUrl/index.php?title=Special:UserRights
 +
# Grant the ''Administrator'' and ''Bureaucrat'' roles (if required)
 +
 +
 +
 +
'''Special page''' > '''Preferences'''
 +
 +
 +
  
 
==Global CSS==
 
==Global CSS==
Line 8: Line 212:
  
 
See http://www.mediawiki.org/wiki/Manual:FAQ  
 
See http://www.mediawiki.org/wiki/Manual:FAQ  
 +
 +
 +
 +
=Clear cache=
 +
 +
Sometimes you need to clear the cache to see the changes ; especially the UI changes (favicon, CSS, logo, ...)
 +
 +
Use the '''&action=purge''' command.
 +
 +
 +
ex: http://www.daxiongmao.eu/wiki/index.php?title=Main_Page&action=purge
 +
 +
  
  
 
=Special content=
 
=Special content=
 +
 +
 +
==Favicon==
 +
 +
1. Copy your FavIcon to the root of your website. It must be either 16x16 or 32x32 in ICO format.
 +
 +
 +
2. Set'' 'favicon.ico' ''rights to 644
 +
 +
 +
3. Adjust your localSettings.php
 +
 +
<syntaxhighlight lang="php">
 +
## FAVICON in PNG
 +
$wgFavicon = "$wgScriptPath/favicon.ico";
 +
</syntaxhighlight>
  
  
Line 21: Line 254:
  
 
Ex: http://www.daxiongmao.eu/wiki/index.php?title=MediaWiki:Sidebar
 
Ex: http://www.daxiongmao.eu/wiki/index.php?title=MediaWiki:Sidebar
 +
 +
  
  
Line 44: Line 279:
 
=Image=
 
=Image=
  
==Enable upload==
+
 
Great tutorial: Enable user image uploads
+
==Image upload configuration==
See: http://www.inmotionhosting.com/support/edu/mediawiki/adding-content-mediawiki/enable-uploads-wiki
+
 
 +
To enable image upload you need to adjust your ''LocalSettings.php'':
 +
 
 +
 
 +
<syntaxhighlight lang="php">
 +
## To enable image uploads, make sure the 'images' directory
 +
## is writable, then set this to true:
 +
$wgEnableUploads = true;
 +
$wgUseImageMagick = false;
 +
$wgImageMagickConvertCommand = "/usr/bin/convert";
 +
#$wgImageMagickTempDir="{$wgUploadDirectory}/temp";
 +
 
 +
 
 +
## If you want to use image uploads under safe mode,
 +
## create the directories images/archive, images/thumb and
 +
## images/temp, and make them all writable. Then uncomment
 +
## this, if it's not already uncommented:
 +
#$wgHashedUploadDirectory = false;
 +
#$wgTmpDirectory = "{$wgUploadDirectory}/temp";
 +
</syntaxhighlight>
 +
 
 +
 
 +
You just have to:
 +
* '''Enable uploads'''
 +
* '''Not''' use ImageMagick
 +
 
 +
 
 +
On previous version of MediaWiki I was able to use ''image magick''. However it seems it doesn't work anymore on OVH shared hosting... :( Instead I now rely on PHP scripts.
 +
 
  
  

Latest revision as of 22:28, 7 July 2016


Installation

Mediawiki

Get the latest mediawiki LTS version from the official website: https://www.mediawiki.org/wiki/MediaWiki


Enable file upload

It is important to enable File Upload so user can push images, videos and all kind of content.

Have a look to the official MediaWiki File Upload manual.


Configuration

Add / Edit the following code at the bottom of your LocalSettings.php:

$wgEnableUploads = true;                   # Enable uploads
$wgUseImageMagick = false;                 # Do NOT use ImageMagick to compute thumbnailed images. 
                                           # It is usually NOT available on shared hosting
$wgImageMagickConvertCommand = "/usr/bin/convert";
ini_set( 'post_max_size', '20M' );         # Max size of a HTTP POST operation (= sum of all files of the operation)
ini_set( 'upload_max_filesize', '10M' );   # Max size of a single file 

# List of allowed extensions to be uploaded
$wgFileExtensions = array( 'png', 'gif', 'jpg', 'jpeg', 'doc', 'xls', 'mpp', 'pdf', 'ppt', 'tiff', 'bmp', 'docx', 'xlsx', 'pptx', 'ps', 'odt', 'ods', 'odp', 'odg');
# To allow ZIP files upload
$wgFileExtensions[] = 'zip';
$wgTrustedMediaFormats[] = 'application/zip';


ERROR 500 fix

If you have problems to see the pictures, you need to adjust the mediawiki/images/.htaccess file to:

<IfModule rewrite_module>
	RewriteEngine On
	RewriteCond %{QUERY_STRING} \.[^\\/:*?\x22<>|%]+(#|\?|$) [nocase]
	RewriteRule . - [forbidden]
</IfModule>


Extensions

You can use Extensions to improve your wiki. You'll find below some recommendations.

You can always browse the official Extensions repository on https://www.mediawiki.org/wiki/Category:Extensions


SyntaxHighlight

This is required to display source code with syntax support.


Download

Please note that the SyntaxHighlight requires SyntaxHighlight_Geshi:


Configuration

Add the following code at the bottom of your LocalSettings.php:

# -------------------- LIST OF EXTENSIONS --------------------
# MediaWiki 1.25+
wfLoadExtension( 'SyntaxHighlight_GeSHi' );

# Old MediaWiki
require_once "$IP/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php";

# -------------------- CONFIGURATION --------------------
$wgSyntaxHighlightDefaultLang = "java";


Install check-up

Navigate to Special:Version on your wiki to verify that the extension is successfully installed.


Source / Help

official SyntaxHighlight help page


WikiEditor

This WYSIWYG editor is much better than the default one!


Download


Configuration

Add the following code at the bottom of your LocalSettings.php:

# -------------------- LIST OF EXTENSIONS --------------------
# MediaWiki 1.25+
wfLoadExtension( 'WikiEditor' );

# Old MediaWiki
require_once "$IP/extensions/WikiEditor/WikiEditor.php";


# -------------------- WikiEditor extension --------------------
# Enables use of WikiEditor by default but still allows users to disable it in preferences
$wgDefaultUserOptions['usebetatoolbar'] = 1;

# Enables link and table wizards by default but still allows users to disable them in preferences
$wgDefaultUserOptions['usebetatoolbar-cgd'] = 1;

# Displays the Preview and Changes tabs
$wgDefaultUserOptions['wikieditor-preview'] = 1;

# Displays the Publish and Cancel buttons on the top right side
$wgDefaultUserOptions['wikieditor-publish'] = 1;
wfLoadExtension( 'SyntaxHighlight_GeSHi' );


Install check-up

Navigate to Special:Version on your wiki to verify that the extension is successfully installed.


Source / Help

official WikiEditor help page


Cite

This extension helps to display and manage sources + references + quotes. This is particularly useful for R&D and training pages.


Download

  • Cite (bundled by default since 1.21)


Configuration

Add the following code at the bottom of your LocalSettings.php:

# -------------------- LIST OF EXTENSIONS --------------------
# MediaWiki 1.25+
wfLoadExtension( 'Cite' );

# Old MediaWiki
require_once "$IP/extensions/Cite/Cite.php";


Source / Help

official Cite help page


How to check the installation?

Navigate to Special:Version on your wiki to verify that the extension is successfully installed and enabled.


How to know what are the current installed extensions?

  • Go to Special:Version




Configuration

Create users and grants rights

  1. As the Admin user go to Special page > Create account
  2. Set the user rights: go to http://wikiUrl/index.php?title=Special:UserRights
  3. Grant the Administrator and Bureaucrat roles (if required)


Special page > Preferences



Global CSS

Edit page: MediaWiki:Common.css

See http://www.mediawiki.org/wiki/Manual:FAQ


Clear cache

Sometimes you need to clear the cache to see the changes ; especially the UI changes (favicon, CSS, logo, ...)

Use the &action=purge command.


ex: http://www.daxiongmao.eu/wiki/index.php?title=Main_Page&action=purge



Special content

Favicon

1. Copy your FavIcon to the root of your website. It must be either 16x16 or 32x32 in ICO format.


2. Set 'favicon.ico' rights to 644


3. Adjust your localSettings.php

## FAVICON in PNG 
$wgFavicon = "$wgScriptPath/favicon.ico";


Sidebar

Just edit MediaWiki:Sidebar

Source: http://www.mediawiki.org/wiki/Manual_talk:Interface/Sidebar


Ex: http://www.daxiongmao.eu/wiki/index.php?title=MediaWiki:Sidebar



Copyright note

To adjust the text edit MediaWiki:Copyright


To configure the copyrights, adjust your LocalSettings.php

Source: http://www.mediawiki.org/wiki/Manual:$wgRightsText

$wgRightsPage = ""; # Set to the title of a wiki page that describes your license/copyright
$wgRightsUrl = "http://creativecommons.org/licenses/by-sa/3.0/";
$wgRightsText = "Creative Commons Attribution Share Alike";
$wgRightsIcon = "$wgScript/wiki/skins/common/images/creative_commons.png";



Image

Image upload configuration

To enable image upload you need to adjust your LocalSettings.php:


## To enable image uploads, make sure the 'images' directory
## is writable, then set this to true:
$wgEnableUploads = true;
$wgUseImageMagick = false;
$wgImageMagickConvertCommand = "/usr/bin/convert";
#$wgImageMagickTempDir="{$wgUploadDirectory}/temp";


## If you want to use image uploads under safe mode,
## create the directories images/archive, images/thumb and
## images/temp, and make them all writable. Then uncomment
## this, if it's not already uncommented:
#$wgHashedUploadDirectory = false;
#$wgTmpDirectory = "{$wgUploadDirectory}/temp";


You just have to:

  • Enable uploads
  • Not use ImageMagick


On previous version of MediaWiki I was able to use image magick. However it seems it doesn't work anymore on OVH shared hosting... :( Instead I now rely on PHP scripts.


Insert images

Great tutorial: How to insert images into a wiki article ? See: http://www.inmotionhosting.com/support/edu/mediawiki/adding-content-mediawiki/insert-images-wiki