MediaWiki

From StrelaWiki
Jump to navigation Jump to search

Install

$ cd /opt/
$ git clone https://gerrit.wikimedia.org/r/p/mediawiki/core.git mediawiki
$ cd mediawiki
$ git clone https://gerrit.wikimedia.org/r/p/mediawiki/vendor.git
$ cd skins
$ git clone https://git.wikimedia.org/git/mediawiki/skins/Vector.git

$ git checkout <branchname OR tag name>
$ git checkout master   # default
$ git checkout 1.18.2   # tag for current (2012-04) version

$ wget https://raw.githubusercontent.com/musinsky/config/master/MediaWiki/mediawiki.conf -P /etc/httpd/conf.d/
$ systemctl restart httpd.service

Config script

http://localhost/mediawiki/mw-config/index.php

All settings will be temporally caching in your browser

Connect to database
Database type: MySQL
Database host: localhost
Database name: strela_wiki
Database table prefix:
Database username: root
Database password: <sql_root_passwd>
Database settings
Use the same account as for installation [uncheck]
Database username: wikiuser
Database password: <sql_wiki_passwd>
Create the account if it does not already exist [check]
Storage engine: InnoDB
Database character set: Binary
Settings will be saved in LocalSettings.php file
Name
Name of wiki: StrelaWiki
Project namespace: Other (specify): StrelaWiki
Administrator account
Your name: WikiAdmin
Password: <wiki_admin_passwd>
E-mail address: musinsky@gmail.com
Ask me more question [check]
Settings will be saved in strela_wiki MySQL database (which will be created soon)
Options
User rights profile: Authorized editors only
...
Settings will be later changed in LocalSettings.php file
Install
Only now MediaWiki installer create strela_wiki MySQL database and LocalSettings.php file

Complete

Save and move generated file LocalSettings.php to the main wiki directory /opt/mediawiki/

$ mv /home/musinsky/LocalSettings.php /opt/mediawiki/
$ chmod 600 /opt/mediawiki/LocalSettings.php
$ chown apache:apache /opt/mediawiki/LocalSettings.php

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

Upgrade

$ cd /opt/mediawiki/
$ git pull
$ php maintenance/update.php

Backup

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

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
  3. 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
  • ToDo
https://www.mediawiki.org/wiki/API:Main_page
https://www.mediawiki.org/wiki/Manual:Reduce_size_of_the_database
https://www.mediawiki.org/wiki/Manual:DeleteOldRevisions.php
https://www.mediawiki.org/wiki/Manual:DeleteArchivedRevisions.php
$ php maintenance/deleteOldRevisions.php 27 # 27 is page id for MediaWiki on strela
Delete old revisions

Limiting to page IDs 27
Searching for active revisions...done.
Searching for inactive revisions...done.
21 old revisions found.

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

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");