MediaWiki: Difference between revisions
mNo edit summary |
mNo edit summary |
||
| Line 40: | Line 40: | ||
== Configuration LocalSettings.php == | == Configuration LocalSettings.php == | ||
Note: | Note: generate a new LocalSettings.php during installation and use this example to make your changes. | ||
The following are enabled in this example: | |||
* Vector skin | |||
* WikiEditor - a bit more help while editing | |||
* Syntax highlighting - easier reading of code | |||
* Allow anonymous talk - only registered users are allowed to edit ages but everyone is allowed to start a discussion | |||
* MobileFrontend - a view for smaller screens | |||
<syntaxhighlight lang=bash> | <syntaxhighlight lang=bash> | ||
Revision as of 13:37, 31 December 2017
Installation and configuration
MySQL database server and PHP Ubuntu
For more info: MySQL
sudo apt-get install apache2 mysql-server php5 php5-mysql
Create wiki database:
sudo mysql -u root mysql -p
SQL:
create database wikidb; grant index, create, select, insert, update, delete, alter, lock tables on wikidb.* to 'wikidbadmin'@'localhost' identified by '**pwd**'; \q
Make sure the settings for your database in LocalSettings.php are correct, then go to the configuration web page, here you can create or upgrade the database:
MediaWiki website files
Download the code and copy to /var/www/mediawiki
Edit LocalSettings.php to add extensions and to customize.
Configuration LocalSettings.php
Note: generate a new LocalSettings.php during installation and use this example to make your changes.
The following are enabled in this example:
- Vector skin
- WikiEditor - a bit more help while editing
- Syntax highlighting - easier reading of code
- Allow anonymous talk - only registered users are allowed to edit ages but everyone is allowed to start a discussion
- MobileFrontend - a view for smaller screens
sudo gedit /var/www/mediawiki/LocalSettings.php
<?php
# Generated by the MediaWiki 1.30.0 installer
# Further documentation for configuration settings may be found at:
# https://www.mediawiki.org/wiki/Manual:Configuration_settings
# Protect against web entry
if ( !defined( 'MEDIAWIKI' ) ) {
exit;
}
## Uncomment this to disable output compression
# $wgDisableOutputCompression = true;
$wgSitename = "WikiWiki";
## The URL base path to the directory containing the wiki, more information:
## https://www.mediawiki.org/wiki/Manual:Short_URL
$wgScriptPath = "/mediawiki";
## The protocol and server name to use in fully-qualified URLs
$wgServer = "https://wilbertvolkers.linkpc.net";
## The URL path to static resources (images, scripts, etc.)
$wgResourceBasePath = $wgScriptPath;
## The URL path to the logo.
$wgLogo = "$wgResourceBasePath/wiki.gif";
$wgFavicon = "$wgResourceBasePath/favicon.ico";
## UPO means: user preference option
$wgEnableEmail = false;
$wgEnableUserEmail = false; # UPO
$wgEmergencyContact = "admin@wilbertvolkers.linkpc.net";
$wgPasswordSender = "admin@wilbertvolkers.linkpc.net";
$wgEnotifUserTalk = false; # UPO
$wgEnotifWatchlist = false; # UPO
$wgEmailAuthentication = true;
## Database settings
$wgDBtype = "mysql";
$wgDBserver = "127.0.0.1";
$wgDBname = "wikidb";
$wgDBuser = "wikidbadmin";
$wgDBpassword = "**wikidbadminpwd**";
# 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 = [];
## Image uploads, make sure the 'images' directory is writable
$wgEnableUploads = true;
#$wgUseImageMagick = true;
#$wgImageMagickConvertCommand = "/usr/bin/convert";
# InstantCommons allows wiki to use images from https://commons.wikimedia.org
$wgUseInstantCommons = false;
# Periodically send a pingback to https://www.mediawiki.org/ with basic data
$wgPingback = 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 = "C.UTF-8";
## 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/data/Names.php
$wgLanguageCode = "en";
$wgSecretKey = "use_generated_secret_key_here";
# Changing this will log out all existing sessions.
$wgAuthenticationTokenVersion = "1";
# Site upgrade key. Must be set to a string (default provided) to turn on the
# web installer while LocalSettings.php is in place
$wgUpgradeKey = "use_generated_upgrade_key_here";
## 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";
## Default skin: you can change the default skin. Use the internal symbolic
## names, ie 'vector', 'monobook':
$wgDefaultSkin = "vector";
# Enabled skins.
wfLoadSkin( 'Vector' );
# Enabled extensions
wfLoadExtension( 'WikiEditor' );
# wjv Enables use of WikiEditor by default but still allows users to disable it in preferences
$wgDefaultUserOptions['usebetatoolbar'] = 1;
# wjv Enables link and table wizards by default but still allows users to disable them in preferences
$wgDefaultUserOptions['usebetatoolbar-cgd'] = 1;
# wjv Displays the Preview and Changes tabs
$wgDefaultUserOptions['wikieditor-preview'] = 1;
# wjv Displays the Publish and Cancel buttons on the top right side
$wgDefaultUserOptions['wikieditor-publish'] = 1;
require_once("$IP/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php");
$wgSyntaxHighlightDefaultLang = "bash";
# permissions: allow admin to delete revisions (visibility)
$wgGroupPermissions['sysop']['deleterevision'] = true;
# permissions: deny anonymous page editing
$wgGroupPermissions['*']['createaccount'] = false;
$wgGroupPermissions['*']['read'] = true;
$wgGroupPermissions['*']['edit'] = false;
# permissions: hide history for anonymous users
$wgHooks['MediaWikiPerformAction'][] =
function( $output, $article, $title, $user, $request, $wiki ) {
if( ( !$user || $user->isAnon() ) && ( $request->getVal('action') == 'history' ) ) {
return false;
}
return true;
};
# extension: allow anonymous discussion/talk
# Note: has to make a small change in TalkRight.class.php to make it work
require_once("$IP/extensions/TalkRight/TalkRight.php");
$wgGroupPermissions['*']['talk'] = true;
# extension: MobileFrontend
wfLoadExtension( "MobileFrontend" );
$wgMFAutodetectMobileView = true;
$wgMFDefaultSkinClass = "SkinVector";
# Show errors in the browser:
#$wgShowExceptionDetails = true;
#Debugging
#error_reporting( -1 );
#ini_set( 'display_errors', 1 );
#$wgDebugLogFile = "/tmp/wikiwiki.log";
System permissions for uploads
sudo chown -R www-data:www-data /var/www/mediawiki/images/ sudo chmod -R 755 /var/www/mediawiki/images/
Change user password using commandline
Set the password for username 'user1' to '**pwd**'.
cd /var/www/mediawiki php maintenance/changePassword.php --user=user1 --password=**pwd**
Apache2 webserver configuration
If you login using http your password will be send over the net in 'clear text'. To force login via https the RewriteRule is added, however, you will also need to configure the SSL part of your website. Read Create certificates for Apache2. See also Apache2 configuration for SOGo and MediaWiki.
PHP configuration
With wikimedia, when you import or export all pages or when you upload images and files, this will take more space and time that normally is allowed by PHP. Change these settings:
sudo gedit `locate php.ini | head -n 1`
... upload_max_filesize = 5M ... post_max_size = 5M ... max_execution_time = 180 ; 3min ... max_input_time = 180 ; 3min
Restart Apache2 to apply the settings:
sudo service apache2 restart
Backup
The most important part to backup is the database, see MySQL#Backup for more information.
The second part is the files that where uploaded, these are typically located in:
/var/www/mediawiki/images/
We could backup this folder but then you will also have thumbnails and other temporary files. Instead we will use the following command to list the mediafiles we want to backup:
cd /var/www/mediawiki/ php maintenance/dumpUploads.php | sed 's~images/~./images/~' | zip ~/Mediafiles.zip -@
To add these to a zip file for example:
cd /var/www/mediawiki/ php maintenance/dumpUploads.php | sed 's~images/~./images/~' | zip ~/MediaWikiImages.zip -@
Categories
Use categories to group your pages by including one or more Category tags:
[[Category:Name]]
Try to distribute your pages evenly over categories, first look here if any of the available categories can be used:
Tips
Keywords
You can make the search tool more efficient if you add synonyms and keywords to a page. You might want to keep these hidden from the reader to keep the text readable . Insert like this:
<!-- hidden text -->
Hotkeys
The tooltips will show you the letter of the shortcut between brackets. You need to press SHIFT+ALT+<letter> to use it.
Shortcuts:
- SHIFT+ALT+Z main page
- SHIFT+ALT+E start edit (if allowed)
- you can also right click on the section or click the [edit] link
- SHIFT+ALT+P preview
- SHIFT+ALT+S save
- SHIFT+ALT+C cancel
Special Import / Export pages
Import (as Admin)
Export pages
Export full contents
Uploaded files (like images) are not included an need to be copied and linked separately.
cd /var/www/mediawiki/ sudo php maintenance/dumpBackup.php --full --uploads > ../wiki_dump.xml
VisualEditor
VisualEditor is a WYSIWYG editor that generates readable Wiki text. Due to limitations I prefer to use WikiEdit.
Limitations:
- Can not edit syntax parts and many other type of blocks, for this you still need to edit the wiki text.
- Depends on Parsoid which runs as an independed server and is a pain to configure
Info:
At the time I needed to checkout beta version 'MediaWiki 1.22wmf8':
git clone https://gerrit.wikimedia.org/r/p/mediawiki/core.git cd core git branch -r | sort -V git checkout origin/wmf/1.22wmf9 cd extensions git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/VisualEditor.git git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Parsoid.git node.js
Download 'node-v0.8.22.tar.gz' (the core files) and 'node-v0.8.22-linux-x64.tar.gz' (the 64 bit specific files) from http://nodejs.org/dist/v0.8.22/ extract these in this order in one folder.
It needed to be exactly this version, newer and older did not work yet.
Go into the folder and build and install this version of node:
./configure --prefix=/opt/nodejs make -j 3 make install
Install Parsoid using npm. Note: you can uninstall by deleting /opt/nodejs:
sudo -i cd Parsoid/js export PATH=$PATH:/opt/nodejs/bin npm install
Start server:
export PATH=$PATH:/opt/nodejs/bin cd /var/www/mediawiki/extensions/Parsoid/js node api/server.js
Go to:
If you want to modify this service you can edit this file:
sudo gedit /var/www/mediawiki/extensions/Parsoid/js/api/ParserService.js
See also
Go to Apache2 webserver to read about installing and configuring Apache2 webserver.
Accidentally committed information that really needs to be removed? Go to: Permanently remove a MediaWiki revision using SQL.
MediaWiki.org help pages
- http://www.mediawiki.org/wiki/Manual:Configuration_settings
- http://www.mediawiki.org/wiki/Help:Formatting
- http://www.mediawiki.org/wiki/Manual:Installing_MediaWiki
- http://www.mediawiki.org/wiki/Manual:Running_MediaWiki_on_Ubuntu
- http://www.mediawiki.org/wiki/Manual:Configuration_settings#Database_settings