MediaWiki

From AliceWiki
Jump to: navigation, search

Install

  • MediaWiki will be installed on Linux (Fedora) in /opt/mediawiki directory with Apache web server and MariaDB database server. Suppose you have root access to the server. MediaWiki will be used "pretty URL" Short URL page address. Download latest MediaWiki tarball and unpack to /opt directory.
$ tar -xzf mediawiki-*.tar.gz -C /opt/
$ chown -R root:root /opt/mediawiki-*/
$ ln -s /opt/mediawiki-*/ /opt/mediawiki

$ wget -nc https://raw.githubusercontent.com/musinsky/config/master/MediaWiki/mediawiki.conf -P /etc/httpd/conf.d/
$ systemctl restart httpd.service
  • You can create your database and user in setup process by running the supplied configuration script (see bellow), but prefer create wiki MariaDB database and user manually (or using phpMyAdmin). It will be more general, useful especially in the future (backup, moving or reinstall wiki). Warning: delete .mysql_history file after running these commands (history store the password).
$ mysql -h localhost -u root
MariaDB [(none)]> CREATE DATABASE my_wiki;
MariaDB [(none)]> CREATE USER 'wikiuser'@'localhost' IDENTIFIED BY 'sql_wiki_passwd';   # change password
MariaDB [(none)]> GRANT ALL PRIVILEGES ON my_wiki.* TO 'wikiuser'@'localhost' WITH GRANT OPTION;

Installation script

Connect to database
Database type MariaDB, MySQL, or compatible $wgDBtype = "mysql";
Database host localhost $wgDBserver = "localhost";
Identify this wiki
 Database name my_wiki $wgDBname = "my_wiki";
 Database table prefix $wgDBprefix = "";
User account for installation
 Database username wikiuser $wgDBuser = "wikiuser";
 Database password sql_wiki_passwd $wgDBpassword = "sql_wiki_passwd";
Database settings
Database account for web access
 Use the same account as for installation
Name
Name of wiki MyWiki $wgSitename = "MyWiki";
Project namespace Same as the wiki name: MyWiki
Administrator account
 Your username WikiAdmin my_wiki.user table (MariaDB)
 Password wiki_admin_passwd my_wiki.user table (MariaDB)
 Email address (optional) my_wiki.user table (MariaDB)
 Share data about this installation
 with MediaWiki developers
(optional) $wgPingback = true;
Ask me more questions Options page
Options
User rights profile Authorized editors only $wgGroupPermissions['*']['createaccount'] = false;
$wgGroupPermissions['*']['edit'] = false;
Copyright and license Creative Commons Attribution-ShareAlike $wgRightsUrl $wgRightsText $wgRightsIcon
Email settings
 Enable outbound email (uncheck) $wgEnableEmail = false;
Skins
 Vector (use this skin as default) $wgDefaultSkin = "vector";
wfLoadSkin( 'Vector' );
Extensions
 ExtensionName (optional) wfLoadExtension( 'ExtensionName' );
Images and file uploads
 Enable file uploads $wgEnableUploads = true;
 Enable Instant Commons (optional) $wgUseInstantCommons = true;
Advanced configuration
 Settings for object caching No caching $wgMainCacheType = CACHE_NONE;
Install
  • Press on continue and you will begin the installation of MediaWiki. Only now MediaWiki installer store settings in LocalSettings.php file and populate my_wiki MariaDB database.
Complete
  • Download generated file LocalSettings.php and move this file to the main wiki directory /opt/mediawiki.
$ mv LocalSettings.php /opt/mediawiki
$ chmod 600 /opt/mediawiki/LocalSettings.php   # contains $wgDBpassword
$ chown apache:apache /opt/mediawiki/LocalSettings.php

Configuration


The LocalSettings.php file provides local configuration settings (based on the DefaultSettings.php file) of a MediaWiki.

$wgServer               = "http://strela.jinr.ru";
$wgLogo                 = "$wgScriptPath/images/strela_logo.png";
$wgFavicon              = "$wgScriptPath/images/strela_icon.png";
$wgShowExceptionDetails = true;

Short URL

$wgScriptPath  = "/mediawiki";
$wgArticlePath = "/wiki/$1";
$wgUsePathInfo = true;
$ wget https://raw.githubusercontent.com/musinsky/config/master/MediaWiki/mediawiki.conf

/etc/httpd/conf.d/mediawiki.conf

File uploads

Uploaded files will be distributed into sub-directories of $wgUploadDirectory (/opt/mediawiki/images/) based on the first two characters of the md5 hash of the filename ($IP/images/a/ab/foo.jpg). If $wgHashedUploadDirectory is false, all images are uploaded in $wgUploadDirectory itself ($IP/images/foo.jpg)

$ chown -R apache:apache /opt/mediawiki/images/
$ chmod -R 755 /opt/mediawiki/images/
$wgEnableUploads       = true;
$wgFileExtensions[]    = "svg";

$wgAllowExternalImages = true;

MediaWiki supports SVG image rendering automatically be rendered as a PNG file. Direct SVG display is not supported in MediaWiki by default, unless you install NativeSvgHandler extension

User rights

$wgGroupPermissions['*']['createaccount'] = false;   # restrict account creation
$wgGroupPermissions['*']['edit']          = false;   # restrict anonymous editing
$wgEnableEmail                            = true;

New users will still be able to be created, but only by WikiAdmin Special:Userlogin

robots.txt

/var/www/html/robots.txt

User-agent: *
Disallow: /mediawiki/
Disallow: /wiki/Special:Search
Disallow: /wiki/Special:Random

Be careful, Disallow: /mediawiki (without '/' at the end) you'll block access to the /mediawiki directory, and search engines will drop your wiki

Sitemap

$ php /opt/mediawiki/maintenance/generateSitemap.php --server=http://alice.saske.sk --urlpath=http://alice.saske.sk --fspath=/var/www/html/
$ ln -s /var/www/html/sitemap-index-alice_wiki.xml /var/www/html/sitemap-index.xml

Sidebar

Privacy policy and Disclaimers

set the content of this pages (as WikiAdmin) to a single hyphen [-]

Extensions

Math

$ cd /opt/mediawiki/extensions
$ git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Math.git

Math extension needs dvipng and cancel packages from TeX Live and symbolic links on latex and dvipng in /usr/bin/

$ ln -s /opt/texlive/201*/bin/x86_64-linux/latex /usr/bin/
$ ln -s /opt/texlive/201*/bin/x86_64-linux/dvipng /usr/bin/
$ ln -s /opt/texlive/201*/bin/x86_64-linux/dvips /usr/bin/
$ yum install ocaml
$ cd Math/math
$ make                 # produce texvc executable file
require_once("extensions/Math/Math.php");
$wgUseMathJax = true;
$wgDefaultUserOptions['math'] = MW_MATH_MATHJAX; // setting MathJax as default rendering option for all users
$ php maintenance/update.php

SimpleMathJax


MathJax

require_once "$IP/extensions/MathJax/MathJax.php";
$wgParserCacheType = CACHE_NONE;
MathJax_Parser::$do_dollar = false;
MathJax_Parser::$do_dollardollar = false;

Collection

$ yum install php-pear-Net-Curl
$ cd /opt/mediawiki/extensions
$ git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Collection.git
$wgCollectionFormats = array(
    'rl' => 'PDF',
    'odf' => 'ODT',
);

see README.txt for instructions

Others

git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/ParserFunctions.git
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Variables.git
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Cite.git
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/SyntaxHighlight_GeSHi.git
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Collection.git
require_once "$IP/extensions/Cite/Cite.php";
require_once "$IP/extensions/Collection/Collection.php";
#require_once "$IP/extensions/Math/Math.php";
require_once "$IP/extensions/MathJax/MathJax.php";
require_once "$IP/extensions/ParserFunctions/ParserFunctions.php";
require_once "$IP/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php";
require_once "$IP/extensions/Variables/Variables.php";
require_once "$IP/extensions/GistHub/GistHub.php";
require_once "$IP/extensions/GistIt/GistIt.php";


wget https://raw.github.com/gist/2370651/GistHub.php -P /opt/mediawiki/extensions/GistHub/
require_once("extensions/GistHub/GistHub.php");



dalej

https://www.mediawiki.org/wiki/Manual:System_administration


mysqldump !!!!! Make sure to specify the correct character set or the restore may fail, check LocalSettings.php to find out which character set it is.

zamena Main_Page na svoju !!! https://www.mediawiki.org/wiki/Manual:Main_Page


https://www.mediawiki.org/wiki/Manual:Page_customizations !!!!!


analogicky => http://localhost/wiki/MediaWiki:Privacy => dont delete, ostavit prazdne http://localhost/wiki/MediaWiki:About => musi vzdy ostat http://localhost/wiki/MediaWiki:Aboutsite => tu nastavim linku (!!!!ak vyprazdnim obsah, zmizne about) http://localhost/wiki/MediaWiki:Disclaimers

https://www.mediawiki.org/wiki/Manual:FAQ#How_do_I_change_the_footer? https://www.mediawiki.org/wiki/Manual:Configuration_settings#Copyright https://www.mediawiki.org/wiki/Manual:Footer

https://www.mediawiki.org/wiki/Help:Signatures

https://www.mediawiki.org/wiki/Manual:Timezone AKO dosiahnut nech pise This page was last edited on 14 April 2020, at 03:32 (UTC).  !!! aj UTC !!!

links https://en.wikipedia.org/wiki/Help:External_link_icons#Hiding_link_icons

Your username will be adjusted to "Skuska" due to technical restrictions.

Mozno daleke todo nastavit mail server pre wiki: https://biowikifarm.net/meta/Mediawiki_installation https://www.mediawiki.org/wiki/Manual:$wgSMTP

https://raw.githubusercontent.com/musinsky/config/master/phpMyAdmin/config.inc.php
https://raw.githubusercontent.com/musinsky/config/master/phpMyAdmin/config.inc.php

dalej 2

Delete the /opt/mediawiki/mw-config/ directory

# Ignore .htaccess files
AllowOverride None

mazat bludy (nejak cez find .httacessss)+ nepotrebne extensions



Backup

TODO

  • Backup MediaWiki (MySQL database + images + LocalSettings.php + others) script wiki-backup.sh. Execute as root user (needed permissions to read LocalSettings.php file)
$ wget https://raw.githubusercontent.com/musinsky/config/master/MediaWiki/wiki-backup.sh

Moving

TODO

Ensure that your "fresh install" consists of the same version of MediaWiki

  1. Backup Backup the database and MediaWiki files
  2. Install Re-create the database, user and permissions
    • create database username: wikiuser with database password: 'sql_wiki_passwd'
    • create database name: strela_wiki with all privileges for wikiuser
$ mysql -u root -p
MariaDB [(none)]> CREATE DATABASE strela_wiki;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON strela_wiki.* TO 'wikiuser'@'localhost' IDENTIFIED BY 'sql_wiki_passwd';
  1. Move
    1. Modify (created file) / copy (previous wiki settings) file LocalSettings.php
      $ chmod 600 LocalSettings.php; chown apache:apache LocalSettings.php
    2. Import the MediaWiki files (copy all MediaWiki files, images/math, images/thumb, images/tmp)
      $ chown -R apache:apache images/; chmod -R 755 images/
    3. Import the database backup
      $ mysql --user=wikiuser --password strela_wiki < strela_wiki-dump_YYYY-MM-DD.sql
    4. Update the database
      $ php /opt/mediawiki/maintenance/update.php