My linux world » mediawiki

mediawiki


Contents

Installation

  1. #!/bin/bash
  2.  
  3. ##################################################
  4. # PARAMETERS
  5. ##################################################
  6.  
  7. database_name=mediawiki
  8. database_username=mediawiki
  9. database_password=mediawiki
  10.  
  11.  
  12. ##################################################
  13. # INSTALL MEDIAWIKI
  14. ##################################################
  15. echo "install prerequistes"
  16. dnf -y install php-mbstring php-xml php-intl php-gd texlive php-mysqli php-xcache
  17.  
  18.  
  19. echo "create database $database_name, user/password $database_username/$database_password":
  20. mysql --user=root --password=root -e "CREATE USER '$database_username'@'localhost' IDENTIFIED BY '$database_password';"
  21. mysql --user=root --password=root -e "CREATE DATABASE IF NOT EXISTS $database_name;"
  22. mysql --user=root --password=root -e "use $database_name; GRANT ALL PRIVILEGES ON $database_name.* TO '$database_username'@'localhost' WITH GRANT OPTION;"
  23.  
  24. echo "download mediawiki"
  25. cd /tmp
  26. wget http://releases.wikimedia.org/mediawiki/1.26/mediawiki-1.26.4.tar.gz
  27. tar xvfz mediawiki-1.26.4.tar.gz
  28. mv mediawiki-1.26.4 /var/www/html/mediawiki
  29.  
  30.  
  31. echo "restart httpd"
  32. systemctl restart httpd.service
  33.  
  34. myip=`hostname -I`
  35. echo "Now meet you here: http://$myip/mediawiki/"

Configure extensions

VisualEditor

The visualeditor extension can be found here : https://www.mediawiki.org/wiki/Extension:VisualEditor

Parsoid installation

# install required packages:
yum -y install nodejs npm git
 
# get parsoid:
cd /opt
npm install parsoid
 
cat > /opt/node_modules/parsoid/localsettings.js << "EOF"
'use strict';
exports.setup = function(parsoidConfig) {
  parsoidConfig.setMwApi({ uri: 'http://srv-intranet/mediawiki/api.php', domain: 'localhost', prefix: 'localhost'  });
};
EOF
 
# open port 8000:
firewall-cmd --permanent --zone=public --add-port=8000/tcp
firewall-cmd --reload
 
# add parsoid service:
cat > /etc/systemd/system/parsoid.service << "EOF"
[Unit]
Description=Mediawiki Parsoid web service on node.js
Documentation=http://www.mediawiki.org/wiki/Parsoid
Wants=local-fs.target network.target
After=local-fs.target network.target
 
[Install]
WantedBy=multi-user.target
 
[Service]
Type=simple
User=root
Group=root
WorkingDirectory=/opt/node_modules/parsoid
ExecStart=/opt/node_modules/parsoid/bin/server.js
KillMode=process
Restart=on-success
PrivateTmp=true
StandardOutput=syslog
EOF
 
systemctl enable parsoid.service
systemctl start parsoid.service

Test
Test, if Parsoid is working: Go to a users computer and open in a browser http://srv-intranet:8000/_wikitext/.
You should now be able to enter some Wiki-code in the form and Parsoid should render in to a correct HTML-page after a click on “Send data”.
https://www.centos.org/forums/viewtopic.php?f=47&t=53223&p=225372#p225372

LocalSettings.php, enable extension

In your LocalSettings.php add this :

require_once "$IP/extensions/VisualEditor/VisualEditor.php";
 
// Enable by default for everybody
$wgDefaultUserOptions['visualeditor-enable'] = 1;
 
// Optional: Set VisualEditor as the default for anonymous users
// otherwise they will have to switch to VE
// $wgDefaultUserOptions['visualeditor-editor'] = "visualeditor";
 
// Don't allow users to disable it
$wgHiddenPrefs[] = 'visualeditor-enable';
 
// OPTIONAL: Enable VisualEditor's experimental code features
#$wgDefaultUserOptions['visualeditor-enable-experimental'] = 1;

// Linking with Parsoid
$wgVirtualRestConfig['modules']['parsoid'] = array(
  // URL to the Parsoid instance
  'url' => 'http://srv-intranet:8000',
  // Parsoid "domain", see below (optional, must be se same as /opt/node_modules/parsoid/localsettings.js)
  'domain' => 'localhost',
  // Parsoid "prefix", see below (optional, must be se same as /opt/node_modules/parsoid/localsettings.js)
  'prefix' => 'localhost'
);

SyntaxHighlight_GeSHi

In LocalSettings.php:

wfLoadExtension( 'SyntaxHighlight_GeSHi' );

And install python-pygments :

yum install python-pygments

UniversalLanguageSelector

Installation

cd /var/www/html/mediawiki/extensions
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/UniversalLanguageSelector.git

Configuration LocalSettings.php

require_once "$IP/extensions/UniversalLanguageSelector/UniversalLanguageSelector.php";

Copyright © 2024 My linux world - by Marc RABAHI
Design by Marc RABAHI and encelades.