======Install Mediawiki======
This page shows how to install Mediawiki on a Linux server.
======Prerequisites======
You must have a CentOS machine already set up in accordance with the the "[[linux:install_centos6|Install CentOS 6]]" guide.
======Add Hard Drive======
Add a 50GB non-independent, thin provisioned disk to hold the wiki data. Store it in vm_secondary on the NetApp. Virtual Device Node should be SCSI 2:0.
su -
pvcreate /dev/sdc
vgcreate datavg /dev/sdc
lvcreate -L 1G -n data datavg
mkfs -t ext4 /dev/mapper/datavg-data
FILENAME=/etc/fstab
echo '/dev/mapper/datavg-data /data ext4 defaults 1 2' >> $FILENAME
mkdir /data
mount -a
======Install Server Software======
- [[linux:install_apache|Apache]]
- [[linux:install_php|PHP]] (including APC)
- [[databases:install_mysql|MySQL]]
======Configure MySQL======
Create a user called 'wikiuser', create a database called 'wikidb' and give the user 'wikiuser' administrator privileges on the database 'wikidb'. Change PASSWORD as needed.
mysql -u root -p
CREATE DATABASE wikidb;
GRANT index, create, select, insert, update, delete, alter, lock tables on wikidb.* to 'wikiuser'@'localhost' identified by 'password';
flush privileges;
exit
======Install Image Processing Software======
su -
yum -y install ImageMagick gd
======Download Mediawiki======
Download Mediawiki from [[http://www.mediawiki.org/wiki/Download|here]].
su -
cd /data/www/html
FILENAME=mediawiki-1.22.6
wget http://download.wikimedia.org/mediawiki/1.22/$FILENAME.tar.gz
tar xvf $FILENAME.tar.gz
rm -f $FILENAME.tar.gz
ln -fs $FILENAME mediawiki
chown -R apache:apache /data/www/html
restorecon -r /data/www/html/mediawiki/
======Install Mediawiki======
Then run the installerhttp://mediawiki.example.com/mediawiki/mw-config/index.php
Note that the default upload directory is /data/www/html/mediawiki/images_wiki/
chmod -R a-x /data/www/html/mediawiki/images_wiki/
cat << EOF >> /etc/httpd/conf/httpd.conf
# From http://www.mediawiki.org/wiki/Manual:Security#Upload_security
# Ignore .htaccess files
AllowOverride None
# Serve HTML as plaintext, don't execute SHTML
AddType text/plain .html .htm .shtml .php
# Don't run arbitrary PHP code.
php_admin_flag engine off
# If you've other scripting languages, disable them too.
EOF
mkdir /data/www/html/images_main
mkdir /data/www/html/images
chmod -R a-x /data/www/html/images_wiki
chmod -R a-x /data/www/html/images_main
chown -R apache:apache /data/www/html/images_wiki
chown -R apache:apache /data/www/html/images_main
Language
* Your Language = en - English
* Wiki language = en - English
Click Continue
Welcome To MediaWiki.
* Assuming there are no errors, click Continue.
Connect to database
* Database type = MySQL
* Database host = localhost
* Database name = wikidb
* Database table prefix = BLANK
* Database username = wikiuser
* Database password = PASSWORD
Click Continue
Database settings
* Tick "Use the same account as for installation"
* Storage engine = InnoDB
* Database character set = Binary
Click Continue
Name
* Name of wiki = Intranet
* Project namespace = Same as the wiki name
* Your name = administrator
* Password = PASSWORD
* Email address = wikiadmin@example.com
* Select "I'm bored already, just install the wiki."
Click Continue.
Install
* Click Continue.
* Click Continue.
Complete!
* Download LoacalSettings.php and copy it over to /data/www/html/mediawikichown apache:apache /data/www/html/mediawiki/LocalSettings.php
* Visit wiki http://mediawiki.example.com/mediawiki/index.php
rm -rf /data/www/html/mediawiki/mw-config/
======Set Customisations======
You will need to run the following as root
pear install MAIL Net_SMTP
Enabling email is done with the following lines
$wgEnableEmail = true;
$wgEnableUserEmail = true; # UPO
$wgSMTP = array(
'host' => "mail.example.com",
'IDHost' => "example.com",
'port' => 25,
'auth' => false
);
In the top left of each page is the 3 and 3 logo. To set it there, edit
vi /data/www/html/mediawiki/LocalSettings.php
Edit wgServer and wgDBpassword
"mail.example.com",
'IDHost' => "example.com",
'port' => 25,
'auth' => false
);
$wgEmergencyContact = "wikiadmin@example.com";
$wgPasswordSender = "wikiadmin@example.com";
$wgEnotifUserTalk = false; # UPO
$wgEnotifWatchlist = false; # UPO
$wgEmailAuthentication = true;
## Database settings
$wgDBtype = "mysql";
$wgDBserver = "localhost";
$wgDBname = "wikidb";
$wgDBuser = "wikiuser";
$wgDBpassword = "SEE KEEPASS";
# MySQL specific settings
$wgDBprefix = "";
# MySQL table options to use during installation or update
$wgDBTableOptions = "ENGINE=InnoDB, DEFAULT CHARSET=binary";
# Experimental charset support for MySQL 5.0.
$wgDBmysql5 = false;
## Shared memory settings
$wgMainCacheType = CACHE_NONE;
$wgMemCachedServers = array();
## To enable image uploads, make sure the 'images' directory
## is writable, then set this to true:
$wgEnableUploads = true;
$wgUseImageMagick = true;
$wgImageMagickConvertCommand = "/usr/bin/convert";
# InstantCommons allows wiki to use images from http://commons.wikimedia.org
$wgUseInstantCommons = false;
## If you use ImageMagick (or any other shell command) on a
## Linux server, this will need to be set to the name of an
## available UTF-8 locale
$wgShellLocale = "en_GB.utf8";
## If you want to use image uploads under safe mode,
## create the directories images/archive, images/thumb and
## images/temp, and make them all writable. Then uncomment
## this, if it's not already uncommented:
#$wgHashedUploadDirectory = false;
## Set $wgCacheDirectory to a writable directory on the web server
## to make your wiki go slightly faster. The directory should not
## be publically accessible from the web.
#$wgCacheDirectory = "$IP/cache";
# Site language code, should be one of the list in ./languages/Names.php
$wgLanguageCode = "en";
$wgSecretKey = "SET BY THE INSTALLER";
# Site upgrade key. Must be set to a string (default provided) to turn on the
# web installer while LocalSettings.php is in place
$wgUpgradeKey = "SET BY THE INSTALLER";
## Default skin: you can change the default skin. Use the internal symbolic
## names, ie 'cologneblue', 'monobook', 'vector':
$wgDefaultSkin = "vector";
## For attaching licensing metadata to pages, and displaying an
## appropriate copyright notice / icon. GNU Free Documentation
## License and Creative Commons licenses are supported so far.
$wgRightsPage = ""; # Set to the title of a wiki page that describes your license/copyright
$wgRightsUrl = "";
$wgRightsText = "";
$wgRightsIcon = "";
# Path to the GNU diff3 utility. Used for conflict resolution.
$wgDiff3 = "/usr/bin/diff3";
# We need this to allow users to upload *.doc files and the like
$wgAllowJavaUploads = true;
# End of automatically generated settings.
# Add more configuration options below.
date_default_timezone_set('Europe/London');
$wgFileExtensions = array('gif','png','jpg','jpeg','svg','vsd','vss','vst','vsw','vdx','vsx','vtx','vsdx','vsdm','vssx','vssm','vstx','vstm','vsl','oft','mhtml','html','htm','edx','mht','xls','doc','xlt','pdf','dot','jpeg','pdn','vbs','docx','docm','dotx','dotm','xlsx','xlsm','xltx','xltm','ppt','pot','pps','pptx','pptm','potx','potm','ppam','ppsx','ppsm','sldx','sldm');
$wgGroupPermissions['*']['createpage'] = false;
$wgGroupPermissions['*']['edit'] = false;
$wgGroupPermissions['*']['read'] = true;
$wgGroupPermissions['*']['upload'] = false;
$wgGroupPermissions['user']['createpage'] = true;
$wgGroupPermissions['user']['edit'] = true;
$wgGroupPermissions['user']['read'] = true;
$wgGroupPermissions['user']['upload'] = true;
$wgGroupPermissions['read']['createpage'] = true;
$wgGroupPermissions['read']['edit'] = true;
$wgGroupPermissions['read']['read'] = true;
$wgGroupPermissions['read']['upload'] = true;
$wgGroupPermissions['write']['createpage'] = true;
$wgGroupPermissions['write']['edit'] = true;
$wgGroupPermissions['write']['read'] = true;
$wgGroupPermissions['write']['upload'] = true;
$wgUrlProtocols = array(
'http://',
'https://',
'mailto:',
'file://',
'//', // for protocol-relative URLs
);
require_once "$IP/extensions/WikiEditor/WikiEditor.php";
$wgDefaultUserOptions['usebetatoolbar'] = 1;
$wgDefaultUserOptions['usebetatoolbar-cgd'] = 1;
$wgDefaultUserOptions['wikieditor-preview'] = 1;
require_once "$IP/extensions/FileProtocolLinks/FileProtocolLinks.php";
require_once("$IP/extensions/PdfHandler/PdfHandler.php");
$wgPdfProcessor = 'gs';
$wgPdfPostProcessor = $wgImageMagickConvertCommand;
$wgPdfInfo = 'pdfinfo';
# Disable cache - otherwise graphs are not updated properly
$wgCachePages = false;
$wgCacheEpoch = max( $wgCacheEpoch, gmdate( 'YmdHis' ) );
# Include libraries
require_once("$IP/extensions/flowchartwiki/flowchartwiki.php");
$fchw['GraphvizDot'] = "/usr/bin/dot";
require_once( "$IP/extensions/ParserFunctions/ParserFunctions.php" );
$wgPFEnableStringFunctions = true;
require_once("$IP/extensions/CSS/CSS.php");
$wgCollectionMWServeURL = 'localhost:8899/';
$wgCollectionFormats = array(
'rl' => 'PDF',
'odf' => 'ODT'
);
require_once("$IP/extensions/Collection/Collection.php");
require_once( "$IP/extensions/pChart4mw/pChart4mw.php" );
======Export Data======
If you are setting up a replacement wiki, you will need to export the data from the old wiki.
The connection and authentication details can be found in the LocalSettings.php file.
mysqldump -h localhost --default-character-set=binary -u root -p wikidb > wikidb.sql
To get just XML (including all history)
php /data/www/html/mediawiki/maintenance/dumpBackup.php --full > /data/www/html/mediawiki/maintenance/dump.xml
To get just XML (current version of pages only)
php /data/www/html/mediawiki/maintenance/dumpBackup.php --current > /data/www/html/mediawiki/maintenance/dump.xml
======Export WikiText======
You may want to bag the wikitext of only a few pages. For this, you can use
http://YOURWIKISERVER/mediawiki/index.php?title=Special:Export
=Import Data=
If you are setting up a replacement wiki, you will need to import data that was exported from the old wiki.
I had to use the root credentials to import the data.
I had the export in a file called live_wiki_backup.sql and I put it in /data/www/html/ on the new server.
cd /data/www/html/
- Backup existing database
mysqldump -h localhost -u wikiuser -p wikidb > pre_import_backup.sql
mysqladmin -u root -p drop wikidb
mysqladmin -u root -p create wikidb
- Import new database
mysql -u root -p --default-character-set=binary wikidb < live_wiki_backup.sql
Then, you need to edit the the database as it isn't perfect
mysql -u root -p
use wikidb;
ALTER TABLE /*$wgDBprefix*/revision ADD rev_sha1 varbinary(32) NOT NULL default '';
exit
It is important to make sure the images directory is ported to /data/www/html/ this point. Copy it over before running the update script.
cd /data/www/html/mediawiki
rm -rf images
ln -s ../images_wiki images
Update the database to work out any differences between wiki version
php /data/www/html/mediawiki/maintenance/update.php
======Install Plugins======
You can use this URL to get information on what versions of software are running on the Wiki
http://wiki/mediawiki/index.php/Special:Version
====WikiEditor====
You can get the latest version of the plugin [[http://www.mediawiki.org/wiki/Special:ExtensionDistributor/WikiEditor|here]].
cd /data/www/html/mediawiki
wget https://codeload.github.com/wikimedia/mediawiki-extensions-WikiEditor/legacy.tar.gz/REL1_22
mv REL1_22 WikiEditor.tar.gz
tar -xzf WikiEditor.tar.gz -C /data/www/html/mediawiki/extensions
rm -f WikiEditor.tar.gz
cd extensions
mv wikimedia-mediawiki-extensions-WikiEditor-* WikiEditor
Configure the plugin
vi /data/www/html/mediawiki/LocalSettings.php
by adding the following to LocalSettings.php
require_once( "$IP/extensions/WikiEditor/WikiEditor.php" );
$wgDefaultUserOptions['usebetatoolbar'] = 1;
$wgDefaultUserOptions['usebetatoolbar-cgd'] = 1;
$wgDefaultUserOptions['wikieditor-preview'] = 1;
====FileProtocolLinks====
Add the following to $IP/extensions/FileProtocolLinks/FileProtocolLinks.php
* @copyright Copyright 2005, Edmund Mielach
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @package MediaWikiExtensions
* @version 0.3.2
*/
/**
* Check if we are being called directly
*/
if ( !defined( 'MEDIAWIKI' ) ) {
die( 'This file is an extension to MediaWiki and thus not a valid entry point.' );
}
/**
* Register this extenion on Special:Version
*/
$wgExtensionCredits['parserhook'][] = array(
'name' => 'FileProtocolLinks',
'author' => array( 'Edmund Mielach', 'Silver Quettier' ),
'version' => '0.3.2',
'description' => 'Allows creation of links to local filesystem or network files',
'url' => 'https://www.mediawiki.org/wiki/Extension:FileProtocolLinks'
);
$wgHooks['ParserFirstCallInit'][] = 'wfRegisterFileProtocolLinks';
/**
* Sets the tag that this extension looks for and the function by which it
* operates
*/
function wfRegisterFileProtocolLinks( Parser $parser ) {
$parser->setHook( 'file', 'renderFileProtocolLink' );
return true;
}
/**
* Renders a file protocol link based on the information provided by $input.
*
* @param string
* The string should be in the following format:
* URI[;link text]
* One example for a Windows environment would be:
* c:/something.txt|some nice text
* @return string
* Returns an anchor tag for the given input. For the example above
* the return string would be
* some nice text
* The links are rendered in green text color to make it easier to recognize
* them as local shares.
*/
function renderFileProtocolLink($input, array $args, Parser $parser, PPFrame $frame) {
$exploded = explode( '|', $input );
$uri = htmlentities( $exploded[0], ENT_COMPAT, "UTF-8" );
if ( !isset( $exploded[1] ) || empty( $exploded[1] ) ) {
// no linktext has been specified ==> use the URI as linktext
$linktext = $uri;
} else {
$linktext = htmlentities( $exploded[1], ENT_COMPAT, "UTF-8" );
}
$linktext = $parser->recursiveTagParse( $linktext, $frame );
$uri = $parser->recursiveTagParse( $uri, $frame );
return sprintf( '%s', $uri, $linktext );
}
Add the following to LocalSettings.php
require_once("$IP/extensions/FileProtocolLinks/FileProtocolLinks.php");
====PdfHandler====
cd /data/www/html/mediawiki/extensions
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/PdfHandler.git
vi /data/www/html/mediawiki/LocalSettings.php
require_once("$IP/extensions/PdfHandler/PdfHandler.php");
$wgPdfProcessor = 'gs';
$wgPdfPostProcessor = $wgImageMagickConvertCommand;
$wgPdfInfo = 'pdfinfo';
====Flowchart====
Disable SELinux. Otherwise the calls to graphviz won't work.
yum install -y graphviz
cd /data/www/html/mediawiki/extensions
wget http://www.flowchartwiki.org/flowchartwiki-1.2.1.zip
unzip flowchartwiki-1.2.1.zip
mv flowchartwiki-1.2.1 flowchartwiki
Import stuff into the database
mysql --user=wikiuser -p wikidb < /data/www/html/mediawiki/extensions/flowchartwiki/maintenance/schema_mysql.sql
mkdir /data/www/html/mediawiki/images/flowchartwiki
chmod 777 /data/www/html/mediawiki/images/flowchartwiki
vi /data/www/html/mediawiki/LocalSettings.php
# Disable cache - otherwise graphs are not updated properly
$wgCachePages = false;
$wgCacheEpoch = max( $wgCacheEpoch, gmdate( 'YmdHis' ) );
- Include libraries
require_once("$IP/extensions/flowchartwiki/flowchartwiki.php");
$fchw['GraphvizDot'] = "/usr/bin/dot";
====ParserFunctions====
cd /data/www/html/mediawiki/extensions
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/ParserFunctions.git
vi /data/www/html/mediawiki/LocalSettings.php
require_once( "$IP/extensions/ParserFunctions/ParserFunctions.php" );
$wgPFEnableStringFunctions = true;
====pChart4mw====
Some departments use this.
Download from [[https://code.google.com/p/pchart4mw/downloads/list|here]].
Extract to the extensions folder. If it extracts to pchart4mw, rename it pChart4mw (Linux is case sensative).
Add the following lines to LocalSettings.php
require_once( "$IP/extensions/pChart4mw/pChart4mw.php" );
====CSS====
Simple install from
http://www.mediawiki.org/wiki/Extension:CSS
{{#css:
#bodyContent { background-color: yellow; }
body {
background: navajowhite;
}
}}
====iFrame====
Enable HTML by adding the following to LocalSettings.php
$wgRawHtml = true;
The following is example code
==ReplaceText====
The page is [[https://www.mediawiki.org/wiki/Extension:Replace_Text|here]].
cd extensions/
git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/ReplaceText.git
require_once( "$IP/extensions/ReplaceText/ReplaceText.php" );
Bear in mind that if you run this and it has a lot of files to update, it will take some time to complete. The process runs in the background so you can leave the page.
======Edit Main Menu======
To edit the menu on the left visit
http://wiki/mediawiki/index.php/MediaWiki:Sidebar
https://wiki/mediawiki/index.php?title=MediaWiki:Sidebar&action=edit
======Upload Files To Wiki======
This will download the latest version of the file.
[[Media:myFile.doc| My File]]
This will take you the the file's page where you can see each version of the file.
[[File:myFile.doc| My File]]
======Make Image a Link======
[[File:ImageName.jpg|100px|link=Wiki_Page_Name]]
======Include a New Line In Pre Tag======
Use & # 1 0 ;
======Get User Addresses======
mysql -u wikiuser -p
use wikidb;
select user_name,user_email from user;
More information can be gained. [[http://www.mediawiki.org/wiki/Manual:User_table|This link]] provides details on the table structure.
======Increase Upload Minute======
The Wiki has an upload file limit of 2mb (default). To raise this (in this case to 10mb), add the following to LocalSettings.php
$wgUploadSizeWarning = 10485760;
$wgMaxUploadSize = 10485760;
Modified php.ini (/etc/php.ini):
upload_max_filesize 10M
post_max_size 10M