From FroggDev - En
Jump to: navigation, search
Wikimedia Logo


  • password change
php maintenance/changePassword.php --user=UserName --password=newpassword
  • set an user as admin (require $wgShowExceptionDetails = true; in LocalSettings.php)
php maintenance/createAndPromote.php --user=UserName --sysop --force
  • set an user as admin via sql
INSERT INTO `user_groups` VALUES (userId, 'sysop');




  • server address
$wgServer = '';
  • allow admin action
$wgShowExceptionDetails = true;
  • customisation
$wgFavicon = '/wiki/images/favicon.ico';
$wgLogo = '/wiki/images/logo.gif';
  • email confirmation
$wgEmailAuthentication = true;
$wgEmailConfirmToEdit = true;

Rights Management

my configuration:

  • offline users (*)
$wgGroupPermissions['*'    ]['createaccount']   = true;
$wgGroupPermissions['*'    ]['read']            = true;
$wgGroupPermissions['*'    ]['edit']            = false;
$wgGroupPermissions['*'    ]['createpage']      = false;
$wgGroupPermissions['*'    ]['createtalk']      = false;
$wgGroupPermissions['*'    ]['talk']            = false;
$wgGroupPermissions['*'    ]['purge']           = false;
$wgGroupPermissions['*'    ]['editmyprivateinfo']= false;
$wgGroupPermissions['*'    ]['editmyusercss']   = false;
$wgGroupPermissions['*'    ]['editmyuserjs']    = false;
$wgGroupPermissions['*'    ]['editmyoptions']   = false;
$wgGroupPermissions['*'    ]['editmywatchlist'] = false;
$wgGroupPermissions['*'    ]['writeapi']        = false;
$wgGroupPermissions['*'    ]['viewmywatchlist'] = false;
$wgGroupPermissions['*'    ]['viewmyprivateinfo']= false;
  • online users (user)
$wgGroupPermissions['user' ]['move']            = false;
$wgGroupPermissions['user' ]['read']            = true;
$wgGroupPermissions['user' ]['edit']            = false;
$wgGroupPermissions['user' ]['createpage']      = false;
$wgGroupPermissions['user' ]['createtalk']      = true;
$wgGroupPermissions['user' ]['edittalk']        = true;
$wgGroupPermissions['user' ]['talk']            = true;
$wgGroupPermissions['user' ]['upload']          = false;
$wgGroupPermissions['user' ]['reupload']        = false;
$wgGroupPermissions['user' ]['reupload-shared'] = false;
$wgGroupPermissions['user' ]['minoredit']       = false;
$wgGroupPermissions['user' ]['purge']           = false;
$wgGroupPermissions['user' ]['movefile']        = false;
$wgGroupPermissions['user' ]['move-subpages']   = false;
$wgGroupPermissions['user' ]['move-categorypages'] = false;
$wgGroupPermissions['user' ]['move-rootuserpages'] = false;
$wgGroupPermissions['user' ]['writeapi']        = false;
$wgGroupPermissions['user' ]['editmyusercss']   = false;
$wgGroupPermissions['user' ]['editmyuserjs']    = false;
$wgGroupPermissions['user' ]['editmyoptions']   = false;
$wgGroupPermissions['user' ]['editmywatchlist'] = false;
$wgGroupPermissions['user' ]['changetags']      = false;
$wgGroupPermissions['user' ]['applychangetags'] = false;
  • bot (bot)
$wgGroupPermissions['bot'  ]['bot']             = true;
$wgGroupPermissions['bot'  ]['autoconfirmed']   = false;
$wgGroupPermissions['bot'  ]['nominornewtalk']  = false;
$wgGroupPermissions['bot'  ]['autopatrol']      = true;
$wgGroupPermissions['bot'  ]['writeapi']        = false;
  • administrator (sysop)
$wgGroupPermissions['sysop']['move']            = true;
$wgGroupPermissions['sysop']['createpage']      = true;
$wgGroupPermissions['sysop']['createtalk']      = true;
$wgGroupPermissions['sysop']['edit']            = true;
$wgGroupPermissions['sysop']['block']           = true;
$wgGroupPermissions['sysop']['createaccount']   = true;
$wgGroupPermissions['sysop']['checkuser']       = true;
$wgGroupPermissions['sysop']['delete']          = true;
$wgGroupPermissions['sysop']['deletedhistory']  = true;
$wgGroupPermissions['sysop']['editinterface']   = true;
$wgGroupPermissions['sysop']['editusercssjs']   = true;
$wgGroupPermissions['sysop']['import']          = true;
$wgGroupPermissions['sysop']['importupload']    = true;
$wgGroupPermissions['sysop']['move']            = true;
$wgGroupPermissions['sysop']['patrol']          = true;
$wgGroupPermissions['sysop']['autopatrol']      = true;
$wgGroupPermissions['sysop']['protect']         = true;
$wgGroupPermissions['sysop']['proxyunbannable'] = true;
$wgGroupPermissions['sysop']['rollback']        = true;
$wgGroupPermissions['sysop']['trackback']       = true;
$wgGroupPermissions['sysop']['upload']          = true;
$wgGroupPermissions['sysop']['reupload']        = true;
$wgGroupPermissions['sysop']['reupload-shared'] = true;
$wgGroupPermissions['sysop']['unwatchedpages']  = true;
$wgGroupPermissions['sysop']['autoconfirmed']   = true;
$wgGroupPermissions['sysop']['upload_by_url']   = true;
$wgGroupPermissions['sysop']['ipblock-exempt']  = true;
$wgGroupPermissions['sysop']['blockemail']      = true;
$wgGroupPermissions['sysop']['purge']           = true;
$wgGroupPermissions['sysop']['writeapi']        = true;
  • user with confirmed email (emailconfirmed)
# Make it so users with confirmed e-mail addresses are in the group.
$wgAutopromote['emailconfirmed'] = APCOND_EMAILCONFIRMED;
# Hide group from user list.
$wgImplicitGroups[] = 'emailconfirmed';
# Finally, set it to true for the desired group.
$wgGroupPermissions['emailconfirmed']['createtalk']     = true;
$wgGroupPermissions['emailconfirmed']['editmyoptions']  = true;
$wgGroupPermissions['emailconfirmed']['editmywatchlist']= true;

#Force ConfirmEmail special pages acces
$wgGroupPermissions['*']['viewmyprivateinfo'] = true;
$wgGroupPermissions['*']['editmyprivateinfo'] = true;

upload/size limit

add the following lines to LocalSettings.php

$wgUploadSizeWarning = 15000000;
$wgMaxUploadSize = 15000000;

Also, modify the following lines in PHP.INI:

memory_limit = 1024M (need to be higher than upload limit)
post_max_size = 15M
upload_max_filesize = 15M

upload/mimes types management

  • mimes types list is in "includes/mime.types"
  • to remove all restriction, you need to add thoose line in LocalSettings.php:

upload/extensions management

$wgFileExtensions is an array who contains all default extensions allowed, can be modified in LocalSettings.php :

Add an extension

$wgFileExtensions[] = 'pdf';

Add some extensions

$wgFileExtensions = array_merge( $wgFileExtensions, array( 'pdf', 'ppt', 'jp2', 'webp' ) );

Reset full array

$wgFileExtensions = array( 'png', 'gif', 'jpg', 'jpeg', 'jp2', 'webp', 'ppt',
                           'pdf', 'psd', 'mp3', 'xls', 'xlsx', 'swf', 'doc',
                           'docx', 'odt', 'odc', 'odp', 'odg', 'mpp');


Wikimedia Code





to force external link, you need to add in LocalSettings.php the line:

$wgExternalLinkTarget = '_blank';

HTML tags

  • allow html tags
$wgRawHtml = true;

this is not recommended, neither securized, and it can conflict with $wgUseTidy for some tags like the links

the best is to use the extension


  • Modify side bar content
  • Style sheet

files are in /skins/{skinName}

  • purge pages cache
  • purge all cache
php maintenance/purgeList.php --purge --all
  • force page access without cache
  • Magic words

official doc:

for example __NOTOC__ Suppresses the appearance of the page's TOC. Can be used anywhere on a page.

  • Special pages
/index.php/Special:Allpages all pages
/index.php/Special:Version description of current wiki
/index.php/Special:Gather list of gathered pages
/index.php/Special:Statistics global stats


official doc:

you can see your curent version in source code off any page in the meta name generator: <meta name="generator" content="MediaWiki 1.25alpha">

  1. get last version of wikimedia on
  2. save your configuration file Localsettings.php, skins & extensions folder
  3. extract new wiki files
  4. put saved Localsettings.php in the new wiki files
  5. add back your extensions & skins
  6. set web user/group rigths (www-data) and if needed, link it to webserver
  7. remove execution from image folder : chmod 550 ${wikifolder}images/* -R
  8. update the database with the linecommand : php maintenance/update.php

Skins & Extensions


  • all referenced skins:


all existing extensions:

  • installed extensions:


official doc:

  • in LocalSettings.php
$wgScriptPath = "";
  • in apache web config
RewriteEngine On
RewriteRule ^(.*)$ %{DOCUMENT_ROOT}/index.php [L]


official doc:

installation description with some wiki who share same ressources (Scenario 4)

Create each wiki

  • install each wiki:

for each language, a wiki need to be created in is own folder; the best practice is to set them in the same main folder, for example:

{Path}/wiki/fr                wiki in french
{Path}/wiki/en                wiki in english
{Path}/wiki/pool              common files

You can use the bash script available there

  • web symbolic links
ln -s {Path}/wiki/fr /var/www/wiki/fr
ln -s {Path}/wiki/en /var/www/wiki/en
ln -s {Path}/wiki/pool /var/www/wiki/pool
  • database installation

you can set a database for each wiki, but the best practice is to set them in the same database with different prefix

préfix fr_          for french wiki
préfix en_          for english wiki
préfix pool_        for common files
  • configuration

interwiki table need this configuration information(ou use special page interwiki menu):

INSERT INTO `wiki`.`interwiki` (`iw_prefix`, `iw_wikiid`, `iw_local`, `iw_trans`) 
	VALUES ('pool', '$1', '1', '1');
INSERT INTO `wiki`.`interwiki` (`iw_prefix`, `iw_wikiid`, `iw_local`, `iw_trans`) 
	VALUES ('fr', '$1', '1', '1');
INSERT INTO `wiki`.`interwiki` (`iw_prefix`, `iw_wikiid`, `iw_local`, `iw_trans`) 
	VALUES ('en', '$1', '1', '1');

INSERT INTO `wiki`.`fr_interwiki` (`iw_prefix`, `iw_wikiid`, `iw_local`, `iw_trans`) 
	VALUES ('pool', '$1', '1', '1');
INSERT INTO `wiki`.`fr_interwiki` (`iw_prefix`, `iw_wikiid`, `iw_local`, `iw_trans`) 
	VALUES ('fr', '$1', '1', '1');
INSERT INTO `wiki`.`fr_interwiki` (`iw_prefix`, `iw_wikiid`, `iw_local`, `iw_trans`) 
	VALUES ('en', '$1', '1', '1');

INSERT INTO `wiki`.`en_interwiki` (`iw_prefix`, `iw_wikiid`, `iw_local`, `iw_trans`) 
	VALUES ('pool', '$1', '1', '1');
INSERT INTO `wiki`.`en_interwiki` (`iw_prefix`, `iw_wikiid`, `iw_local`, `iw_trans`) 
	VALUES ('fr', '$1', '1', '1');
INSERT INTO `wiki`.`en_interwiki` (`iw_prefix`, `iw_wikiid`, `iw_local`, `iw_trans`) 
	VALUES ('en', '$1', '1', '1');

INSERT INTO `wiki`.`pool_interwiki` (`iw_prefix`, `iw_wikiid`, `iw_local`, `iw_trans`) 
	VALUES ('pool', '$1', '1', '1');
INSERT INTO `wiki`.`pool_interwiki` (`iw_prefix`, `iw_wikiid`, `iw_local`, `iw_trans`) 
	VALUES ('fr', '$1', '1', '1');
INSERT INTO `wiki`.`pool_interwiki` (`iw_prefix`, `iw_wikiid`, `iw_local`, `iw_trans`) 
	VALUES ('en', '$1', '1', '1');
  • LocalSettings.php of each wiki need extra command lines:
 $wgGroupPermissions['sysop']['interwiki'] = true ;
  • common file sharing
$wgUseSharedUploads = true;
$wgHashedSharedUploadDirectory = true;
$wgUploadNavigationUrl = $wgServer."/wiki_pool/index.php/Special:Upload";
$wgSharedUploadPath = $wgServer."/wiki_pool/images";
$wgSharedUploadDirectory = "/opt/wiki/pool/images/";

$wgFetchCommonsDescriptions = true;
$wgSharedUploadDBname = 'wiki';
$wgSharedUploadDBprefix = 'pool_';
$wgRepositoryBaseUrl = $wgServer."/wiki_pool/index.php/Image:";
  • database sharing
$wgInterwikiCentralDB = 'wiki';
$wgSharedDB = 'wiki';
$wgSharedPrefix = 'fr_';
$wgSharedTables = array('user','user_groups','interwiki','ipblocks');
  • multidomain interwiki cookie sharing
$wgCookieDomain = '';


to prevent to much duplicated configuration , LocalSetting.php can be split with common part in shared config file, this is my version: click here to see all detail of my optimised settings

Add lang tag in your pages

  • to activate lang, you need to add this code in each pages:

Site Map

  • generate sitemap.xml
cd /opt/web/wiki/fr
mkdir -p sitemap
php maintenance/generateSitemap.php \
	--fspath sitemap \
	--server \
	--urlpath \
	--conf LocalSettings.php
  • bonus 1: move & rename xml generated to root/sitemap.xml
mv $(echo sitemap/*.xml) sitemap.xml
  • bonus 2: register sitemap on google webmaster tools:

Increase security

Official Doc

  • Security

  • Anti Spam/Robot

Wiki configuration

  • modify the secret key in LocalSetting.php (with a random long text)
$wgSecretKey = "H3r34nYT3xT2S2cUR3y0uRW1k1";
  • check user email on account creation
$wgEmailConfirmToEdit = true;
$wgEmailAuthentication = true;
  • set user rights

Link to Rights Management

  • Add my script to remove Special page & purge access to non-sysop users

Link to Remove access to non-sysop user script

Wiki Extensions

  • Add an anti-bot captcha

  • convert email adress in images anti-bot

  • visualize user rights

PHP Configuration

modify php config file php.ini (under linux : /etc/php5/apache2/php.ini)

allow_url_fopen off

Increase performances

Official doc:


  • LocalSettings.php
# Uncomment this to disable output compression
# $wgDisableOutputCompression = true;
# Shared memory settings
$wgMainCacheType = CACHE_ACCEL; #PHP APC
#$wgMainCacheType = CACHE_NONE;
$wgMemCachedServers = array(); 

# Parser Cache
$wgParserCacheExpireTime = 604800; #1 Week

# Load.php expires
$wgResourceLoaderMaxage['versioned']['server'] = 604800;
$wgResourceLoaderMaxage['versioned']['client'] = 604800;
$wgResourceLoaderMaxage['unversioned']['server'] = 604800;
$wgResourceLoaderMaxage['unversioned']['client'] = 604800;

# Job.php rate
$wgJobRunRate = 0;

# Sidebar cache
$wgEnableSidebarCache = true;

# File cache
$wgUseFileCache = true;
$wgFileCacheDirectory  = "$IP/cache";
$wgUseGzip = true;
$wgFileCacheDepth = 0;

# Cache folder
$wgCacheDirectory = "$IP/cache";
  • $wgJobRunRate = 0 will no longer starts job each x pages, so task has to be added to /etc/crontab instead
0 0 * * * /usr/bin/php php /var/www/wiki/fr/maintenance/runJobs.php --conf /var/www/wiki/fr/LocalSettings.php > /var/log/wiki/runJobsFr.log 2>&1



SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml application$

BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
AddType image/x-icon .ico
ExpiresByType image/ico "access plus 1 year"
ExpiresByType image/icon "access plus 1 year"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresByType application/xhtml+xml "access plus 1 week"
ExpiresByType text/html "access plus 1 week"
ExpiresByType text/css "access plus 1 week"
ExpiresByType application/javascript "access plus 1 week"
ExpiresByType text/x-javascript "access plus 1 week"
ExpiresDefault "access plus 1 month"

<IfModule mod_headers.c>
<FilesMatch "\\.(ico|jpe?g|png|gif|swf|gz|ttf)$">
Header set Cache-Control "max-age=2797200, public"
<FilesMatch "\\.(css)$">
Header set Cache-Control "max-age=2797200, public"
<FilesMatch "\\.(js)$">
Header set Cache-Control "max-age=2797200, private"
<filesMatch "\\.(html|htm)$">
Header set Cache-Control "max-age=86400, public"
# Disable caching for scripts and other dynamic files
<FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$">
Header unset Cache-Control

For more information about Apache click here


server statistic:

Google Pagespeed Insights results


Script install/update/save/rollback

  • options for wiki:
    • bash -install : to install wiki
    • bash -update : to update wiki
    • bash -backup : to backup wiki
    • bash -rollback : to rollbak wiki
  • options for mysql & phpmyadmin:
    • bash -mysqlupdate: to update mysql & phpmyadmin
    • bash -mysqlbackup : to backup mysql & phpmyadmin
    • bash -mysqlrollback : to rollback mysql & phpmyadmin
  • more options:
    • bash -changepass : to linux & wiki password change
    • bash -{command} -confirm : autoconfirmation

Remove access to non-sysop user

  • remove the access to non-sysop user for Special & Purge (redirect user to login screen)

wiki extension :


  • Global Debug
$wgShowExceptionDetails = true;
$wgDebugToolbar = true;
$wgShowDebug = true;
$wgDevelopmentWarnings = true;
  • Sql Debug
$wgShowSQLErrors = true;
$wgDebugDumpSql = true;
$wgShowDBErrorBacktrace = true;
  • Debug in LogFile
 $wgDebugLogFile = "/tmp/{$wgSitename}-debug.log"


IRC server & IRC chanel