Installation

De Wiki de Jordan LE NUFF
Sauter à la navigation Sauter à la recherche
Ligne 367 : Ligne 367 :
  
 
===Logo===
 
===Logo===
Dans le dossier <code>${WIKI_INSTALL_DIR}/DATA/images</code>, dépôt du logo <code>my_great_company_logo_180x120.png</code>.
+
Dans le dossier <code>${WIKI_INSTALL_DIR}/DATA/images</code>, dépôt du logo <code>my_great_company_logo_180x120.png</code> et de la favicon <code>faviconMyGreatCompany.ico</code>.
  
 
Dans le fichier <code>${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php</code>, modification de la section suivante :
 
Dans le fichier <code>${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php</code>, modification de la section suivante :
<syntaxhighlight lang="php" highlight="5">
+
<syntaxhighlight lang="php" highlight="5-8">
 
...
 
...
  
Ligne 377 : Ligne 377 :
 
$wgLogos = [ '1x' => "$wgResourceBasePath/images/my_great_company_logo_180x120.png" ];
 
$wgLogos = [ '1x' => "$wgResourceBasePath/images/my_great_company_logo_180x120.png" ];
  
 +
## The URL path of the shortcut icon.
 +
$wgFavicon = "$wgResourceBasePath/images/faviconMyGreatCompany.ico";
 
...
 
...
 
</syntaxhighlight>
 
</syntaxhighlight>

Version du 17 juin 2021 à 10:19

Présentation

Cette page a pour objet de décrire comment installer une instance de MediaWiki.

Contexte

Cette procédure sera réalisée avec les éléments techniques suivants :

  • Serveur : serveur CentOs 7
  • Groupe d'utilisateurs : www
  • Serveur web : Apache 2.4
  • Utilisateur : www
  • PHP : version 7.3.27 en mode PHP-FPM
    • Utilisateur : php-fpm
  • MediaWiki : version 1.35.2

Le MedaWiki sera accessible dans un sous-dossier /wikiIsFun dans l'URL.

Prérequis

Pour les prérequis, il suffit de respecter ceux qui sont listés dans la documentation officielle de MediaWiki.

Variables nécessaires à l'installation

Pour faciliter le déploiement, sa portabilité et son éventuellement automatisation, il est nécessaire de définir les variables suivantes :

  • export PHP_VERSION=7.3.27
    Version de PHP à utiliser
  • export WIKI_INSTALL_DIR=/data/www/wikis/wikiIsFun
    Dossier général du mediawiki
  • export WIKI_HOME=${WIKI_INSTALL_DIR}/CURRENT
    Dossier de l'instance principale du mediawiki

Installation PHP

mkdir -p /local/php/php-${PHP_VERSION}
wget https://www.php.net/distributions/php-${PHP_VERSION}.tar.gz
tar -zxf php-${PHP_VERSION}.tar.gz -C /local/builds
cd /local/builds/php-${PHP_VERSION}
./configure \
--prefix=/local/php/php-${PHP_VERSION} \
--with-config-file-path=/local/php/php-${PHP_VERSION} \
--disable-all \
--enable-cli \
--enable-static \
--enable-fpm \
--with-fpm-user=php-fpm \
--with-fpm-group=php-fpm \
--with-fpm-systemd \
--disable-ipv6 \
--enable-calendar \
--enable-intl \
--enable-mbstring \
--enable-zip \
--enable-filter \
--enable-tokenizer \
--enable-xmlwriter \
--enable-xmlreader \
--enable-simplexml \
--with-ldap \
--with-mysqli \
--with-curl \
--with-openssl \
--with-zlib \
--enable-pdo \
--with-pdo-mysql \
--enable-shared=pdo-mysql \
--enable-phar \
--enable-opcache \
--with-libdir=lib64 \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-webp-dir \
--with-bz2 \
--enable-json \
--enable-hash \
--with-pear \
--enable-xml \
--enable-libxml \
--enable-session \
--enable-ctype \
--with-iconv \
--enable-fileinfo \
--enable-dom && make -j && make install
cp /local/php/php-${PHP_VERSION}/etc/php-fpm.conf.default /local/php/php-${PHP_VERSION}/etc/php-fpm.conf
sed -i -e 's@;pid = run/php-fpm.pid@;pid = run/php-fpm.pid\npid = run/php-fpm.pid@g' /local/php/php-${PHP_VERSION}/etc/php-fpm.conf
cp /local/builds/php-${PHP_VERSION}/php.ini-production /local/php/php-${PHP_VERSION}/php.ini
sed -i -e 's@;error_log = syslog@;error_log = syslog\nerror_log = /data/logs/localhost/localhost_php-${PHP_VERSION}.log@g' /local/php/php-${PHP_VERSION}/php.ini
sed -i -e 's@;sendmail_path =@sendmail_path = "/usr/bin/msmtp -t"@g' /local/php/php-${PHP_VERSION}/php.ini
sed -i -e 's@;sendmail_path =@sendmail_path = "/usr/sbin/sendmail -t -i"@g' /local/php/php-${PHP_VERSION}/php.ini
sed -i -e 's@;date.timezone =@date.timezone = "Europe/Paris"@g' /local/php/php-${PHP_VERSION}/php.ini
sed -i -e 's@\[opcache\]@\[opcache\]\nzend_extension='$(grep no-debug-non-zts /local/php/php-${PHP_VERSION}/bin/php-config|awk -F\' '{print $2}')'/opcache.so@g' /local/php/php-${PHP_VERSION}/php.ini
/local/php/php-${PHP_VERSION}/bin/pear config-set php_ini /local/php/php-${PHP_VERSION}/php.ini system
/local/php/php-${PHP_VERSION}/bin/pecl config-set php_ini /local/php/php-${PHP_VERSION}/php.ini system
cat <<EOF >/local/php/php-${PHP_VERSION}/etc/php-fpm.d/localhost.conf
[localhost]
listen = /local/php/sockets/php-${PHP_VERSION}_\$pool.sock
listen.owner = php-fpm
listen.group = www
listen.mode = 0660
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.status_path = /php-fpm-status
ping.path = /php-fpm-ping
access.log = /data/logs/\$pool/\$pool_php-${PHP_VERSION}.access.log
slowlog = /data/logs/\$pool/\$pool_php-${PHP_VERSION}.log.slow
php_admin_value[error_log] = /data/logs/\$pool/\$pool_php-${PHP_VERSION}.log
php_admin_flag[log_errors] = on
php_admin_value[error_reporting] = E_ALL
php_admin_value[session.save_path] = "/local/php/sessions/\$pool/"
php_value[session.save_path] = "/local/php/\$pool/"
EOF
mkdir -p /local/php/sockets
mkdir -p /local/php/sessions
chown -R php-fpm:www /local/php
cp /local/builds/php-${PHP_VERSION}/sapi/fpm/php-fpm.service /usr/lib/systemd/system/php-fpm-${PHP_VERSION}.service
sed -i -e 's/\[Service\]/\[Service\]\nUMask=0007\nUser=php-fpm\nGroup=www\nEnvironment="PHP_VERSION='${PHP_VERSION}'"/g' /usr/lib/systemd/system/php-fpm-${PHP_VERSION}.service
sed -i -e 's/^ProtectKernelModules/#ProtectKernelModules/g' /usr/lib/systemd/system/php-fpm-${PHP_VERSION}.service
sed -i -e 's/^ProtectKernelTunables/#ProtectKernelTunables/g' /usr/lib/systemd/system/php-fpm-${PHP_VERSION}.service
sed -i -e 's/^ProtectControlGroups/#ProtectControlGroups/g' /usr/lib/systemd/system/php-fpm-${PHP_VERSION}.service
sed -i -e 's/^RestrictRealtime/#RestrictRealtime/g' /usr/lib/systemd/system/php-fpm-${PHP_VERSION}.service
sed -i -e 's/^RestrictNamespaces/#RestrictNamespaces/g' /usr/lib/systemd/system/php-fpm-${PHP_VERSION}.service
chmod o+r /usr/lib/systemd/system/php-fpm-${PHP_VERSION}.service
systemctl daemon-reload
systemctl start php-fpm-${PHP_VERSION}.service
systemctl enable php-fpm-${PHP_VERSION}.service
pecl install apcu

Commandes

Téléchargement et déploiement des sources du MediaWiki :

wget https://releases.wikimedia.org/mediawiki/1.35/mediawiki-1.35.2.zip
unzip mediawiki-1.35.2.zip
mkdir -p ${WIKI_INSTALL_DIR}/{DATA/images,LOG,PARAM}
mv mediawiki-1.35.2 ${WIKI_INSTALL_DIR}/
cd ${WIKI_INSTALL_DIR}
ln -s mediawiki-1.35.2 CURRENT
mv CURRENT/images/* DATA/images/
mv CURRENT/images/.htaccess DATA/images/
rmdir CURRENT/images
ln -s ../DATA/images CURRENT/images
chown -R php-fpm:www .
chmod -R ug+X .

Création de la base de données :

CREATE DATABASE wikiIsFun_db;
CREATE USER 'wikiIsFun_user'@'localhost' IDENTIFIED BY 'xxxxxxxxxxxxxxxxxx';
GRANT ALL PRIVILEGES ON wikiIsFun_db.* TO 'wikiIsFun_user'@'localhost' WITH GRANT OPTION;

Création des dossiers pour le fonctionnement du socket PHP :

mkdir /data/logs/wikiIsFun /data/sessions/wikiIsFun
chown php-fpm:www /data/logs/wikiIsFun /data/sessions/wikiIsFun
chmod 770 /data/logs/wikiIsFun /data/sessions/wikiIsFun

Contenu de la configuration du socket PHP pour wikiIsFun /local/php/php-${PHP_VERSION}/etc/php-fpm.d/wikiIsFun.conf :

[wikiIsFun]
;Paramètres du socket
listen = ../sockets/php-${PHP_VERSION}-$pool.sock
listen.owner = php-fpm
listen.group = www
listen.mode = 0660

; Définition du chemin d'accès des logs
access.log = /data/logs/$pool/$pool_php-${PHP_VERSION}.access.log
slowlog = /data/logs/$pool/$pool_php-${PHP_VERSION}.slow.log
php_admin_value[error_log] = /data/logs/$pool/$pool_php-${PHP_VERSION}.error.log
php_admin_flag[log_errors] = on
php_admin_flag[display_errors] = on
; https://www.php.net/manual/fr/errorfunc.constants.php
php_admin_value[error_reporting] = E_ALL
php_admin_value[session.save_path] = "/data/sessions/$pool/"
php_value[session.save_path] = "/data/sessions/$pool/"

; Tuning du pool php-fpm
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.status_path = /php-fpm-status
ping.path = /php-fpm-ping

Rechargement de PHP pour prise en compte de la nouvelle configuration :

systemctl reload php-fpm-${PHP_VERSION}

Tester, grâce à la présence de l'option --env-checks, l'installation du MediaWiki avec la commande suivante :

cd CURRENT/
php maintenance/install.php --confpath=${WIKI_INSTALL_DIR}/PARAM --dbserver=127.0.0.1 --dbname=wikiIsFun_db --dbuser=wikiIsFun_user --dbpass=xxxxxxxxxxxxxxxxx --lang=fr --server="http://mygreat.domain.com" --scriptpath=/wikiIsFun --with-extensions --pass=funwikiadm --env-checks "Médiawiki Fun" "admwikiisfun"

Exemple de retour :

Putty icon.png Console SSH

Lancer pour de bon, grâce à l'absence de l'option --env-checks, l'installation du MediaWiki avec la commande suivante :

php maintenance/install.php --confpath=${WIKI_INSTALL_DIR}/PARAM --dbserver=127.0.0.1 --dbname=wikiIsFun_db --dbuser=wikiIsFun_user --dbpass=xxxxxxxxxxxxxxxxx --lang=fr --server="http://mygreat.domain.com" --scriptpath=/wikiIsFun --with-extensions --pass=funwikiadm "Médiawiki Fun" "admwikiisfun"
Putty icon.png Console SSH

Le fichier ${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php a été créé. Lancer les commandes suivantes pour sa prise en compte dans le MediaWiki :

chown php-fpm:www ../PARAM/LocalSettings.php
ln -s ../PARAM/LocalSettings.php LocalSettings.php

Configuration

URL courtes et Apache

Ajout à la configuration Apache /local/www/httpd-2.4.39/conf/sites/02_mygreat.domain.com.conf du contenu suivant :

...
	# Configuration WikiIsFun
	Alias /mediawikiIsFun ${WIKI_HOME}
	Alias /wikiIsFun ${WIKI_HOME}/index.php
	<Directory "${WIKI_HOME}">
		Options FollowSymLinks
		RewriteEngine On
		RewriteRule ^/*$ %{DOCUMENT_ROOT}/w/index.php [L]
		DirectoryIndex index.php
		AllowOverride All
		Require all granted
		<FilesMatch \.php$>
			SetHandler "proxy:unix:/local/php/sockets/php-7.3.27-wikiIsFun.sock|fcgi://localhost"
		</FilesMatch>
	</Directory>
	# Fin de configuration WikiIsFun
...
systemctl reload http.service

Dans le fichier ${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php, modification de la section suivante :

...
$wgScriptPath = "/wikiIsFun";
...

Par :

...
$wgScriptPath = "/mediawikiIsFun";
$wgScriptExtension = ".php";
$wgArticlePath = "/wikiIsFun/$1";
$wgUsePathInfo = true;
...

Le mediawiki est désormais accessible sur http://mygreat.domain.com/wikiIsFun/

Style CSS personnalisé

En reprenant les couleurs du logo de l'entreprise au format hexadécimal grâce à un color picker (exemple : https://imagecolorpicker.com/), modification de la CSS principale du MediaWiki (MediaWiki:Common.css) avec le contenu suivant :

/* Le CSS placé ici sera appliqué à tous les habillages. */

/* Désactiver l'onglet Discussion */
#ca-talk { display:none!important; }

h1,h2 {
	color: #335875;
}

h3,h4 {
	color: 	#538da5;
}

h5,h6 {
	color: #57b1cd;
}

h3,h4,h5 {
	border-bottom-width: 1px;
	border-bottom-style: solid;
	border-bottom-color: rgb(162, 169, 177);
}

h6 {
	font-weight: normal;
}

div#content h1, div#content h2 {
	font-weight: bold;
	font-family: sans-serif;
}

Logs

Dans le fichier ${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php, ajout de la section suivante :

...
$wgUsePathInfo = true;

/**
 * The debug log file must never be publicly accessible because it
 * contains private data. But ensure that the directory is writeable by the
 * PHP script running within your Web server.
 * The filename is with the database name of the wiki.
 */
$wgDebugLogFile = "$IP/../LOG/mediawiki_debug.log";

## The protocol and server name to use in fully-qualified URLs
...

Dans le dossier ${WIKI_INSTALL_DIR}/DATA/images, dépôt du logo my_great_company_logo_180x120.png et de la favicon faviconMyGreatCompany.ico.

Dans le fichier ${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php, modification de la section suivante :

...

## The URL paths to the logo.  Make sure you change this from the default,
## or else you'll overwrite your logo when you upgrade!
$wgLogos = [ '1x' => "$wgResourceBasePath/images/my_great_company_logo_180x120.png" ];

## The URL path of the shortcut icon.
$wgFavicon = "$wgResourceBasePath/images/faviconMyGreatCompany.ico";
...

Ajout de types de fichier particuliers

Afin de pouvoir téléverser des types de fichier non-standard, il faut ajouter le type de fichier attendu dans le tableau PHP $wgFileExtensions. Il faut également désactiver la vérification des types MIME en fonction de l'extension de fichier avec la variable $wgVerifyMimeType.

Ce type d'ajout présentant une faille de sécurité, il convient de n'activer cette configuration que lorsque c'est nécessaire, et de la commenter une fois le téléversement terminé.

Ainsi, dans le fichier ${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php, ajout de la section (commentée) suivante :

# Autoriser des extensions de fichiers supplémentaires à l'upload
//$wgFileExtensions[] = 'rpm';

# Désactiver la vérification des types MIME en fonction de l'extension de fichier lors de l'upload
//$wgVerifyMimeType  = false;

Nom de l'exécutable du client PHP cli

Dans le fichier ${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php, ajout de la section suivante :

...

/**
 * Executable path of the PHP cli binary. Should be set up on install.
 */
$wgPhpCli = '/local/php/php-${PHP_VERSION}/bin/php';

Ajout du protocole file://

Dans le fichier ${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php, ajout de la section suivante :

...

/**
 * URL schemes that should be recognized as valid by wfParseUrl().
 *
 * WARNING: Do not add 'file:' to this or internal file links will be broken.
 * Instead, if you want to support file links, add 'file://'. The same applies
 * to any other protocols with the same name as a namespace. See task T46011 for
 * more information.
 *
 * @see wfParseUrl
 */
$wgUrlProtocols[] = "file://";

/**
 * Autorise l'activation des fonctions intégrées de manipulation des chaînes
 * (voir https://www.mediawiki.org/wiki/Extension:StringFunctions). La valeur
 * par défaut est false
 */
$wgPFEnableStringFunctions = true;

Créer le modèle Modèle:Unc et y ajouter le contenu suivant :

[file:///{{#replace:{{#replace:{{{1}}}| |%20}}|\|/}} {{#if:{{{2|}}}|{{{2}}}}}]

Activation des sous-pages

Configuration

Pour activer les sous-pages dans l'espace de noms principal, dans le fichier ${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php, ajout de la section suivante :

...

/**
 * Which namespaces should support subpages?
 * See Language.php for a list of namespaces.
 */
$wgNamespacesWithSubpages[NS_MAIN] = true;

Astuce pour le titre de la sous-page

Par défaut, dans le thème Vector, les titres des sous-pages reprennent le chemin complet du nom de la page. Par exemple :

MaPremièrePage/MaPremièreSous-Page/MaDeuxièmeSous-Page

Afin d'avoir un affichage du titre de la sous-page plus convivial, modifier le fichier ${WIKI_INSTALL_DIR}/CURRENT/skins/Vector/includes/VectorTemplate.php en ajoutant la ligne suivante :

115 ...
116 		$out = $skin->getOutput();
117 		$out->setPageTitle(Title::newFromText($out->getTitle()->getSubpageText()));
118 		$title = $out->getTitle();
119 ...

Ainsi, les titres des sous-pages ressembleront à ceci :

MaDeuxièmeSous-Page

Rendre le mediawiki privé

Pour rendre le mediawiki privé (pas de création de compte, pas de lecture ni d'écriture des pages), dans le fichier ${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php, ajout de la section suivante :

...

# Restrictions d'accès au mediawiki
$wgGroupPermissions['*']['createaccount'] = false;
$wgGroupPermissions['*']['edit'] = false;
$wgGroupPermissions['*']['read'] = false;
# Fin des restrictions d'accès au mediawiki
...

Autoriser l'affichage d'images hors mediawiki

Pour pouvoir afficher des images provenant d'autres sites, dans le fichier ${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php, ajout de la section suivante :

...

/**
 * If the above is false, you can specify an exception here. Image URLs
 * that start with this string are then rendered, while all others are not.
 * You can use this to set up a trusted, simple repository of images.
 * You may also specify an array of strings to allow multiple sites
 *
 * @par Examples:
 * @code
 * $wgAllowExternalImagesFrom = 'http://127.0.0.1/';
 * $wgAllowExternalImagesFrom = [ 'http://127.0.0.1/', 'http://example.com' ];
 * @endcode
 */
$wgAllowExternalImagesFrom = [ 'http://mydata.visualization.solution/' ];

Configuration pour Visual Editor

Ajout à la configuration Apache /local/www/httpd-2.4.39/conf/sites/02_mygreat.domain.com.conf du contenu suivant :

...
	# Paramètre obligatoire pour VisualEditor du mediawiki 1.35
	AllowEncodedSlashes NoDecode
...

Redémarrer Apache :

systemctl reload http.service

Authentification Active Directory

Selon la documentation officielle du MediaWiki sur l'intégration d'une authentification avec un Active Directory, il faut installer les extensions suivantes :

Installation de l'extension LDAPProvider

Téléchargement de l'extension :

wget https://extdist.wmflabs.org/dist/extensions/LDAPProvider-REL1_35-27fccf1.tar.gz

Déploiement de l'extension dans le dossier des extensions du mediawiki :

tar -xzf LDAPProvider-REL1_35-27fccf1.tar.gz -C ${WIKI_HOME}/extensions

Ajout de l'extension dans la configuration du mediawiki :

sed -i $(sed -n '/wfLoadExtension/=' ${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php|tail -1)"awfLoadExtension( 'LDAPProvider' );" ${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php

Mise à jour de la base de données pour prise en compte de la nouvelle extension :

php ${WIKI_HOME}/maintenance/update.php

Ajout de la section de configuration suivante dans le fichier ${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php :

...

# LDAP extensions configuration
$wgGroupPermissions['*']['autocreateaccount'] = true;
$LDAPProviderDomainConfigProvider = function() {
	$config =
	[
		'MyADCompany' =>
		[
			'connection' =>
			[
				"server" => "ldap.mydomain.com",
				"user" => "CN=xxxxxxxxxx,OU=xxxxxxxxxxx,OU=xxxxxxxxxxxxxxxxxx,DC=mydomain,DC=com",
				"pass" => 'xxxxxxxxxxxxxxxxx',
				"basedn" => "DC=mydomain,DC=com",
				"groupbasedn" => "DC=mydomain,DC=com",
				"userbasedn" => "DC=mydomain,DC=com",
				"searchattribute" => "sAMAccountName",
				"searchstring" => "USER-NAME@mydomain.com",
				"usernameattribute" => "samaccountname",
				"realnameattribute" => "displayName",
				"emailattribute" => "mail",
				"grouprequest" => "MediaWiki\\Extension\\LDAPProvider\\UserGroupsRequest\\GroupMember::factory",
			],
		],
	];
	return new \MediaWiki\Extension\LDAPProvider\DomainConfigProvider\InlinePHPArray( $config );
};
# End of LDAP extensions configuration

Installation de l'extension PluggableAuth

Téléchargement de l'extension :

wget https://extdist.wmflabs.org/dist/extensions/PluggableAuth-REL1_35-d036ae0.tar.gz

Déploiement de l'extension dans le dossier des extensions du mediawiki :

tar -xzf PluggableAuth-REL1_35-d036ae0.tar.gz -C ${WIKI_HOME}/extensions

Ajout de l'extension dans la configuration du mediawiki :

sed -i $(sed -n '/wfLoadExtension/=' ${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php|tail -1)"awfLoadExtension( 'PluggableAuth' );" ${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php

Ajout de la section de configuration suivante dans le fichier ${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php :

...
# LDAP extensions configuration
$wgPluggableAuth_ButtonLabel = "Se connecter au MediaWiki";
$wgGroupPermissions['*']['autocreateaccount'] = true;
$LDAPProviderDomainConfigProvider = function() {
...

Installation de l'extension LDAPAuthorization

Téléchargement de l'extension :

wget https://extdist.wmflabs.org/dist/extensions/LDAPAuthorization-REL1_35-2139d67.tar.gz

Déploiement de l'extension dans le dossier des extensions du mediawiki :

tar -xzf LDAPAuthorization-REL1_35-2139d67.tar.gz -C ${WIKI_HOME}/extensions

Ajout de l'extension dans la configuration du mediawiki :

sed -i $(sed -n '/wfLoadExtension/=' ${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php|tail -1)"awfLoadExtension( 'LDAPAuthorization' );" ${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php

Ajout de la section de configuration suivante dans le fichier ${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php :

...
# LDAP extensions configuration
$wgPluggableAuth_ButtonLabel = "Se connecter au MediaWiki";
$wgGroupPermissions['*']['autocreateaccount'] = true;
$LDAPProviderDomainConfigProvider = function() {
	$config =
	[
		'MyADCompany' =>
		[
			'connection' =>
			[
...
			],
			"authorization" =>
			[
				"rules" =>
				[
					"groups" =>
					[
						"required" =>
						[
							"CN=My_First_Group,OU=MyGroups,OU=A_random_OU,DC=mydomain,DC=com",
							"CN=My_Second_Group,OU=MyGroups,OU=Another_random_OU,DC=mydomain,DC=com",
						],
					],
				],
			],
		],
	];
	return new \MediaWiki\Extension\LDAPProvider\DomainConfigProvider\InlinePHPArray( $config );
};
# End of LDAP extensions configuration

Installation de l'extension LDAPAuthentication2

Téléchargement de l'extension :

wget https://extdist.wmflabs.org/dist/extensions/LDAPAuthentication2-REL1_35-26cbd3e.tar.gz

Déploiement de l'extension dans le dossier des extensions du mediawiki :

tar -xzf LDAPAuthentication2-REL1_35-26cbd3e.tar.gz -C ${WIKI_HOME}/extensions

Ajout de l'extension dans la configuration du mediawiki :

sed -i $(sed -n '/wfLoadExtension/=' ${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php|tail -1)"awfLoadExtension( 'LDAPAuthentication2' );" ${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php

Ajout de la ligne suivante dans le fichier ${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php :

...
	return new \MediaWiki\Extension\LDAPProvider\DomainConfigProvider\InlinePHPArray( $config );
};

$LDAPAuthentication2UsernameNormalizer = 'strtolower';
# End of LDAP extensions configuration

Installation de l'extension LDAPGroups

Téléchargement de l'extension :

wget https://extdist.wmflabs.org/dist/extensions/LDAPGroups-REL1_35-008d2d9.tar.gz

Déploiement de l'extension dans le dossier des extensions du mediawiki :

tar -xzf LDAPGroups-REL1_35-008d2d9.tar.gz -C ${WIKI_HOME}/extensions

Ajout de l'extension dans la configuration du mediawiki :

sed -i $(sed -n '/wfLoadExtension/=' ${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php|tail -1)"awfLoadExtension( 'LDAPGroups' );" ${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php

Ajout de la section de configuration suivante dans le fichier ${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php :

...
# LDAP extensions configuration
$wgPluggableAuth_ButtonLabel = "Se connecter au MediaWiki";
$wgGroupPermissions['*']['autocreateaccount'] = true;
$LDAPProviderDomainConfigProvider = function() {
	$config =
	[
		'MyADCompany' =>
		[
			'connection' =>
			[
...
			],
			"authorization" =>
			[
...
			],
			"groupsync" =>
			[
				"mechanism" => "mappedgroups",
				"mapping" =>
				[
					"sysop" => "CN=My_First_Group,OU=MyGroups,OU=A_random_OU,DC=mydomain,DC=com",
					"interface-admin" => "CN=My_First_Group,OU=MyGroups,OU=A_random_OU,DC=mydomain,DC=com",
					"user" => "CN=My_First_Group,OU=MyGroups,OU=A_random_OU,DC=mydomain,DC=com",
					"user" => "CN=My_Second_Group,OU=MyGroups,OU=Another_random_OU,DC=mydomain,DC=com",
				],
			],
		],
	];
	return new \MediaWiki\Extension\LDAPProvider\DomainConfigProvider\InlinePHPArray( $config );
};
...

Installation de l'extension LDAPUserInfo

Téléchargement de l'extension :

wget https://extdist.wmflabs.org/dist/extensions/LDAPUserInfo-REL1_35-c9c0cc1.tar.gz

Déploiement de l'extension dans le dossier des extensions du mediawiki :

tar -xzf LDAPUserInfo-REL1_35-c9c0cc1.tar.gz -C ${WIKI_HOME}/extensions

Ajout de l'extension dans la configuration du mediawiki :

sed -i $(sed -n '/wfLoadExtension/=' ${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php|tail -1)"awfLoadExtension( 'LDAPUserInfo' );" ${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php

Ajout de la section de configuration suivante dans le fichier ${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php :

...
# LDAP extensions configuration
$wgPluggableAuth_ButtonLabel = "Se connecter au MediaWiki";
$wgGroupPermissions['*']['autocreateaccount'] = true;
$LDAPProviderDomainConfigProvider = function() {
	$config =
	[
		'MyADCompany' =>
		[
			'connection' =>
			[
...
			],
			"authorization" =>
			[
...
			],
			"groupsync" =>
			[
...
			],
			"userinfo" =>
			[
				"attributes-map" =>
				[
					"email" => "mail",
					"realname" => "displayName",
				],
			],
		],
	];
	return new \MediaWiki\Extension\LDAPProvider\DomainConfigProvider\InlinePHPArray( $config );
};
...

Ajout de l'extension Realnames

Téléchargement de l'extension :

wget https://github.com/ofbeaton/mediawiki-realnames/archive/refs/tags/0.7.0.tar.gz

Déploiement de l'extension dans le dossier des extensions du mediawiki :

tar -xzf 0.7.0.tar.gz -C ${WIKI_HOME}/extensions
mv ${WIKI_HOME}/extensions/mediawiki-realnames-0.7.0 ${WIKI_HOME}/extensions/Realnames

Ajout de l'extension dans la configuration du mediawiki :

sed -i $(sed -n '/wfLoadExtension/=' ${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php|tail -1)"awfLoadExtension( 'Realnames' );" ${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php

Ajout de l'extension SubPageList

Se rendre dans le dossier applicatif du MediaWiki et lancer un composer require :

cd ${WIKI_HOME}
composer require mediawiki/sub-page-list "~1.6"
cd

Dans le fichier ${WIKI_HOME}/extensions/SubPageList/SubPageList.settings.php, modification de la section suivante :

23 ...
24         // Automatically invalidate the cache of "base pages" when creating, moving or deleting a subpage?
25         // This covers most cases where people expect automatic refresh of the sub page list.
26         // However note that this will not update lists displaying subpages from pages different then themselves.
27         $egSPLAutorefresh = true;
28 
29 } );

Ajout de l'extension LabeledSectionTransclusion

Téléchargement de l'extension :

wget https://extdist.wmflabs.org/dist/extensions/LabeledSectionTransclusion-REL1_35-8b0ba69.tar.gz

Déploiement de l'extension dans le dossier des extensions du mediawiki :

tar -xzf LabeledSectionTransclusion-REL1_35-8b0ba69.tar.gz -C ${WIKI_HOME}/extensions

Ajout de l'extension dans la configuration du mediawiki :

sed -i $(sed -n '/wfLoadExtension/=' ${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php|tail -1)"awfLoadExtension( 'LabeledSectionTransclusion' );" ${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php

Ajout de l'extension MsUpload

Téléchargement de l'extension :

wget https://extdist.wmflabs.org/dist/extensions/MsUpload-REL1_35-583f3a9.tar.gz

Déploiement de l'extension dans le dossier des extensions du mediawiki :

tar -xzf MsUpload-REL1_35-583f3a9.tar.gz -C ${WIKI_HOME}/extensions

Ajout de l'extension dans la configuration du mediawiki :

sed -i $(sed -n '/wfLoadExtension/=' ${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php|tail -1)"awfLoadExtension( 'MsUpload' );" ${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php

Ajout de l'extension ClipUpload

Téléchargement de l'extension :

wget https://github.com/SLboat/ClipUpload/archive/master.zip

Déploiement de l'extension dans le dossier des extensions du mediawiki :

unzip master.zip
mv ClipUpload-master ${WIKI_HOME}/extensions/ClipUpload

Ajout de l'extension dans la configuration du mediawiki :

sed -i $(sed -n '/wfLoadExtension/=' ${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php|tail -1)"arequire_once \"\$IP/extensions/ClipUpload/ClipUpload.php\";" ${WIKI_INSTALL_DIR}/PARAM/LocalSettings.php

Correction du bug "Invalid CSRF token" lors de l'upload d'image avec un mediawiki 1.35 :

sed -i 's/editToken/csrfToken/g' ${WIKI_HOME}/extensions/ClipUpload/js/inline-attach.js

Options supplémentaires

Activer la coloration syntaxique

La configuration est déjà présente pour la coloration syntaxique. Il faut juste autoriser l'utilisateur web du serveur à exécuter le binaire pygmentize avec la commande suivante :

chmod u+x ${WIKI_HOME}/extensions/SyntaxHighlight_GeSHi/pygments/pygmentize