Mediawiki

From Wiki
Jump to navigation Jump to search

Install on Ubuntu

  • ASSUMPTION: MySQL is already installed
  • install the following packages:
apt install imagemagick php-cli php-fpm php-mbstring php-mysql php-xml
  • If the web server is running under a separate deploy user, you will need to edit /etc/php/7.?/fpm/pool.d/www.conf and change the user for listen.owner and listen.group

Upgrade from tarball

  • read all Release Notes
  • download new tarball from http://www.mediawiki.org/wiki/Download
  • unpack in deploy@myserver:wiki/
  • copy over LocalSettings.php (which is a pointer to ~/wiki/var/LocalSettings.php)
  • make images point to ../var/images
  • in extensions, make links to folders in ~/wiki/var/extensions
  • make a link to your ../var/my-logo-image.png file (and make sure $wgLogo matches in LocalSettings.php)
  • run the database update script:
php maintenance/update.php

Increase the maximum upload file size

  • Edit /etc/php5/apache2/php.ini to change this line:
; Maximum allowed size for uploaded files.
upload_max_filesize = 200M
  • restart apache

Allow additional file types for upload

  • Edit /etc/mediawiki/LocalSettings.php and add something like this:
$wgFileExtensions = array('png', 'gif', 'jpg', 'jpeg', 'doc', 'xls', 'pdf', 'txt');

Add your own logo image

  • create a 135x135-pixel logo image and save as png
  • copy the png file to /var/lib/mediawiki1.10/skins/common/images
  • edit /etc/mediawiki1.10/LocalSettings.php to include this line:
$wgLogo = "/mediawiki/skins/common/images/mylogo.png";

Clean up the navigation sidebar

Lowercase Page Titles

  • This helps you fix the titles of pages like "iPhone" that mediawiki automatically converts to "IPhone".
  • install and enable the ParserFunctions extension:
apt-get install mediawiki-extensions (if not already installed)
mwenext ParserFunctions.php
  • open the page Template:Lowercase_title for editing.
  • add this code:
<span>{{DISPLAYTITLE:{{#if:{{NAMESPACE}}|{{NAMESPACE}}:|}}{{lcfirst:{{PAGENAME}}}}}}</span><noinclude>
{{documentation}}
</noinclude>

This can be found on Wikipedia: http://en.wikipedia.org/w/index.php?title=Template:Lowercase_title&action=edit

  • add this line to the top of each affected page:
{{lowercase title}}

Syntax highlighting

Use the GeSHi extension included with mediawiki-extensions: http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi

Custom edit buttons

if (mwCustomEditButtons) {
 
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "images/2/23/Button_code.png",
     "speedTip": "inline <code> tag",
     "tagOpen": "<code>",
     "tagClose": "</code>",
     "sampleText": "Insert code here"};
 
  mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "images/3/3c/Button_pre.png",
     "speedTip": "block <pre> tag",
     "tagOpen": "<pre>\n",
     "tagClose": "\n</pre>",
     "sampleText": "Insert code here"}
}
  • hold down the shift key and hit refresh on the browser to get the page to completely reload

Delete History

  • Make sure the php5-cli package is installed.
  • cd to /usr/share/mediawiki/maintenance
  • run this:
sudo php deleteOldRevisions.php --delete

Back up the wiki

Use a command like this to dump the wiki database to a flat file:

/usr/bin/mysqldump --opt -u barney -pXXXXXXXX wikidb > /backup/wikidb.sql

May need this command in mysql to get it to work:

grant lock tables on *.* to barney@localhost;
flush privileges;

OLD

Setup

On Ubuntu, install the mediawiki package. May also want mediawiki-extensions and mediawiki-math.

https://help.ubuntu.com/community/MediaWiki

  • uncomment alias line of /etc/apache2/conf.d/mediawiki1.10.conf
  • restart apache2
  • open a browser window and visit http://localhost/mediawiki
  • fill out installation form
  • move /var/lib/mediawiki1.10/config/LocalSettings.php to /etc/mediawiki1.10/