MediaWiki/Notes

From Omnia
Revision as of 05:26, 8 March 2015 by Kenneth (talk | contribs) (→‎Wiki Customizations)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Manual:Short URL - MediaWiki - Short URL

http://www.mediawiki.org/wiki/Manual:Short_URL

-

Issue:

Warning: The intl PECL extension is not available to handle Unicode normalization, falling back to slow pure-PHP implementation.

Solution:

yum install php-intl

-

Clean Up Skins

mkdir -p .archive/skins
cd skins
mv cologneblue CologneBlue.php modern Modern.php monobook MonoBook.php ../.archive/skins/
cd ..
# ugly! - have to remove skin references from Resources.php, or get warnings in log messages
# comment out sections for cologneblue, modern, monobook
vi resources/Resources.php

-

# INSTALL MEMCACHED (or APC)

# BROWSE TO URL AND FINISH CONFIGURATION
# (ie. http://127.0.0.1/wiki)
# Specify memcache such as: 127.0.0.1:11211
# CONFIG - get LocalSettings.php from installer and place in same folder as index.php
mv mw-config .archive/


LocalSettings.php

<?php
# This file was automatically generated by the MediaWiki 1.18.2
# installer. If you make manual changes, please keep track in case you
# need to recreate them later.
#
# See includes/DefaultSettings.php for all configurable settings
# and their default values, but don't forget to make changes in _this_
# file, not there.
#
# Further documentation for configuration settings may be found at:
# http://www.mediawiki.org/wiki/Manual:Configuration_settings

# Protect against web entry
if ( !defined( 'MEDIAWIKI' ) ) {
        exit;
}

## Uncomment this to disable output compression
# $wgDisableOutputCompression = true;

$wgSitename      = "Oracle";
$wgMetaNamespace = "OracleWiki";

## The URL base path to the directory containing the wiki;
## defaults for all runtime URL paths are based off of this.
## For more information on customizing the URLs please see:
## http://www.mediawiki.org/wiki/Manual:Short_URL
$wgScriptPath       = "";
$wgScriptExtension  = ".php";

## The protocol and server name to use in fully-qualified URLs
$wgServer           = "https://wiki.example.com";

## The relative URL path to the skins directory
$wgStylePath        = "$wgScriptPath/skins";

## The relative URL path to the logo.  Make sure you change this from the default,
## or else you'll overwrite your logo when you upgrade!
$wgLogo             = "$wgStylePath/common/images/wiki.png";

## UPO means: this is also a user preference option

$wgEnableEmail      = false;
$wgEnableUserEmail  = true; # UPO

$wgEmergencyContact = "apache@wiki.example.com";
$wgPasswordSender   = "apache@wiki.example.com";

$wgEnotifUserTalk      = false; # UPO
$wgEnotifWatchlist     = false; # UPO
$wgEmailAuthentication = true;

## Database settings
$wgDBtype           = "mysql";
$wgDBserver         = "localhost";
$wgDBname           = "notes";
$wgDBuser           = "notes";
$wgDBpassword       = "notes";

# MySQL specific settings
$wgDBprefix         = "";

# MySQL table options to use during installation or update
$wgDBTableOptions   = "ENGINE=InnoDB, DEFAULT CHARSET=binary";

# Experimental charset support for MySQL 4.1/5.0.
$wgDBmysql5 = false;

## Shared memory settings
$wgMainCacheType    = CACHE_ACCEL;
$wgMemCachedServers = array();

## To enable image uploads, make sure the 'images' directory
## is writable, then set this to true:
$wgEnableUploads  = false;
$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_US.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 = "6a87c9285f67ae5eda4858d5df56310ded8fe81cbd10d8f8f57c3a17c63fcbdd";

# Site upgrade key. Must be set to a string (default provided) to turn on the
# web installer while LocalSettings.php is in place
$wgUpgradeKey = "3715f50a4b6302d1";

## Default skin: you can change the default skin. Use the internal symbolic
## names, ie 'standard', 'nostalgia', '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 = "";
# $wgRightsCode = ""; # Not yet used

# Path to the GNU diff3 utility. Used for conflict resolution.
$wgDiff3 = "/usr/bin/diff3";

# Query string length limit for ResourceLoader. You should only set this if
# your web server has a query string length limit (then set it to that limit),
# or if you have suhosin.get.max_value_length set in php.ini (then set it to
# that value)
$wgResourceLoaderMaxQueryLength = -1;

# The following permissions were set based on your choice in the installer
$wgGroupPermissions['*']['createaccount'] = false;
$wgGroupPermissions['*']['edit'] = false;
$wgGroupPermissions['*']['read'] = false;


# End of automatically generated settings.
# Add more configuration options below.


## MODIFICATIONS BY KENNETH ##

# http://meta.wikimedia.org/wiki/Using_a_very_short_URL
$wgScriptPath       = "";
$wgScript           = "$wgScriptPath/index.php";
$wgRedirectScript   = "$wgScriptPath/redirect.php";
$wgArticlePath      = "$wgScriptPath/$1";

# http://www.mediawiki.org/wiki/Manual:$wgEnableMWSuggest - Enable AJAX autocomplete search suggestions
$wgEnableMWSuggest = true;

# Embedding external images
# http://meta.wikimedia.org/wiki/Help:Images_and_other_uploaded_files#Embedding_external_images
$wgAllowExternalImages = true;

# Enable sub pages - http://www.mediawiki.org/wiki/Help:Subpages
$wgNamespacesWithSubpages[NS_MAIN] = true;
<?php
# This file was automatically generated by the MediaWiki 1.22.6
# installer. If you make manual changes, please keep track in case you
# need to recreate them later.
#
# See includes/DefaultSettings.php for all configurable settings
# and their default values, but don't forget to make changes in _this_
# file, not there.
#
# Further documentation for configuration settings may be found at:
# http://www.mediawiki.org/wiki/Manual:Configuration_settings

# Protect against web entry
if ( !defined( 'MEDIAWIKI' ) ) {
        exit;
}

## Uncomment this to disable output compression
# $wgDisableOutputCompression = true;

$wgSitename = "Omnia";
$wgMetaNamespace = "Omnia";

## The URL base path to the directory containing the wiki;
## defaults for all runtime URL paths are based off of this.
## For more information on customizing the URLs
## (like /w/index.php/Page_title to /wiki/Page_title) please see:
## http://www.mediawiki.org/wiki/Manual:Short_URL
$wgScriptPath = "";
$wgScriptExtension = ".php";

## The protocol and server name to use in fully-qualified URLs
$wgServer = "http://omnia.oeey.com";

## The relative URL path to the skins directory
$wgStylePath = "$wgScriptPath/skins";

## The relative URL path to the logo.  Make sure you change this from the default,
## or else you'll overwrite your logo when you upgrade!
$wgLogo             = "$wgStylePath/common/images/wiki.png";

## UPO means: this is also a user preference option

$wgEnableEmail = false;
$wgEnableUserEmail = false; # UPO

$wgEmergencyContact = "omnia@oeey.com";
$wgPasswordSender = "omnia@oeey.com";

$wgEnotifUserTalk = false; # UPO
$wgEnotifWatchlist = false; # UPO
$wgEmailAuthentication = false;

## Database settings
$wgDBtype = "mysql";
$wgDBserver = "localhost";
$wgDBname = "notes";
$wgDBuser = "notes";
$wgDBpassword = "notes";

# 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_ACCEL;
$wgMemCachedServers = array();

## To enable image uploads, make sure the 'images' directory
## is writable, then set this to true:
$wgEnableUploads = false;
$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_US.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 = "b90e402aef4cfafbe8b3996c0842621634f1ff3f2417cc8d4535a43fe6a0757d";

# Site upgrade key. Must be set to a string (default provided) to turn on the
# web installer while LocalSettings.php is in place
$wgUpgradeKey = "f0f433d17034bf37";

## 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 = "http://creativecommons.org/licenses/by/3.0/";
$wgRightsText = "Creative Commons Attribution";
$wgRightsIcon = "{$wgStylePath}/common/images/cc-by.png";

# Path to the GNU diff3 utility. Used for conflict resolution.
$wgDiff3 = "/usr/bin/diff3";

# The following permissions were set based on your choice in the installer
$wgGroupPermissions['*']['createaccount'] = false;
$wgGroupPermissions['*']['edit'] = false;


# End of automatically generated settings.
# Add more configuration options below.




## MODIFICATIONS BY KENNETH ##

# http://meta.wikimedia.org/wiki/Using_a_very_short_URL
$wgScriptPath       = "";
$wgScript           = "$wgScriptPath/index.php";
$wgRedirectScript   = "$wgScriptPath/redirect.php";
$wgArticlePath      = "$wgScriptPath/$1";

# Embedding external images
# http://meta.wikimedia.org/wiki/Help:Images_and_other_uploaded_files#Embedding_external_images
$wgAllowExternalImages = true;

# Enable sub pages - http://www.mediawiki.org/wiki/Help:Subpages
$wgNamespacesWithSubpages[NS_MAIN] = true;

# CC License
$wgRightsUrl = "http://creativecommons.org/licenses/by-sa/3.0/";
$wgRightsText = "Creative Commons Attribution-ShareAlike";
$wgRightsIcon = "{$wgStylePath}/common/images/cc-by-sa.png";

Restricting Access

This article had some useful information...

The problem with this method is the text in the protected pages can still be searched on, and displayed in the search results.

MediaWiki Cite Extention

Cite.php [1]

Cite [2]

Cite.php is a Cite extension that adds two parser hooks to MediaWiki, <ref> and <references> these operate together to add citations to pages.

Installation

To install the Cite extension from CVS, change to your MediaWiki installation directory and do the following:

cvs -d :pserver:anonymous@wikipedia.cvs.sourceforge.net:/cvsroot/wikipedia/ login
cvs -d :pserver:anonymous@wikipedia.cvs.sourceforge.net:/cvsroot/wikipedia/ co extensions/Cite

Wiki Admin Guides

System Administrator's Handbook

Wiki Maintenance Guide



MediaWiki is slow, how can I make it faster?

MediaWiki is slow, how can I make it faster?

  • First you should try a PHP cache engine such as eAccelerator or APC. It will save the parsed PHP scripts and enhance performance a lot (this is something you should use anyway on any PHP installation with non-trivial traffic). Zend Platform also contains a bytecode cache, however its "dynamic content caching" is not supported in MediaWiki at the current time.
  • Use Squid or MediaWiki's native file cache ($wgUseFileCache = true) to cache whole pages
  • Memcached will provide some performance benefit, especially for heavily viewed sites. See also the cache section of the configuration settings.
  • See the Reduction section of the configuration setting.
  • See the $wgUseDatabaseMessages setting.
  • Switching the MySQL table type to MyISAM may be faster for single-user wikis on lower-end computers. See also: MySQL Storage Comparison.
  • Disable ImageMagick in LocalSettings.php $wgUseImageMagick, though this will cause reduced thumbnail quality. ImageMagick imposes a performance penalty during various page views and edits and can slow down bulk uploads.
  • For a heavy concurrent write load, InnoDB is essential. Set $wgAntiLockFlags = ALF_NO_LINK_LOCK | ALF_NO_BLOCK_LOCK to reduce lock contention, at the expense of introducing occasional inconsistencies. Use memcached not the default MySQL-based object cache.

Caching

Use: Accelerator, APC, XCache or WinCache. (for object caching support)

"Wikipedia saves bandwidth by instructing your web browser to store many parts of the site in its local cache (normally on your hard drive), so that they are downloaded only once. This includes articles you've previously viewed, images previously displayed, style sheets, JavaScript, etc."
"Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: press Cmd-Opt-E."
  1. You can use ?action=purge on individual pages to update their cache dates.
  2. There is a global $wgCacheEpoch variable which can be set in LocalSettings.php to invalidate all prior cache entries (see DefaultSettings.php)
  3. If you want to purge all pages in the parser cache, truncate objectcache table from the wiki database. You may use this command:
    • TRUNCATE TABLE objectcache;
    • Hint: If this fails, you might be using a prefix for your database tables!
  4. A shell script such as this may be used

PHP eAccelerator

PHP eAccelerator

Home: http://eaccelerator.net/

"eAccelerator is a free open-source PHP accelerator & optimizer. It increases the performance of PHP scripts by caching them in their compiled state, so that the overhead of compiling is almost completely eliminated. It also optimizes scripts to speed up their execution. eAccelerator typically reduces server load and increases the speed of your PHP code by 1-10 times.
eAccelerator was born in December 2004 as a fork of the Turck MMCache project. Turck MMCache was created by Dmitry Stogov and much of the eAccelerator code is still based on his work.
eAccelerator stores compiled PHP scripts in shared memory and executes code directly from it. It creates locks only for a short time, while searching for a compiled PHP script in the cache, so one script can be executed simultaneously by several engines. Files that can't fit in shared memory are cached on disk only. " [3]

Install PHP eAccelerator:

# RPM Method:
wget http://dag.wieers.com/rpm/packages/php-eaccelerator/php-eaccelerator-5.1.6_0.9.5.2-4.el5.rf.i386.rpm
rpm -Uvh php-eaccelerator-5.1.6_0.9.5.2-4.el5.rf.i386.rpm

# Yum Method:
rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
yum install php-eaccelerator

# Restart apache service
service httpd restart

Configure MediaWiki:

# MediaWiki LocalSettings.php
$wgMainCacheType = CACHE_ACCEL;

To test:

phpinfo.php:
<?php phpinfo(); ?>
echo "<?php phpinfo(); ?>" | php | grep "eAccelerator support"
This program makes use of the Zend Scripting Language Engine:
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
    with eAccelerator v0.9.5.2, Copyright (c) 2004-2006 eAccelerator, by eAccelerator
eAccelerator
eAccelerator support	enabled
Version 	0.9.5.2 

---

Manually Build PHP eAccelerator

NOTE: "The shared memory caching functions (eaccelerator_get and eaccelerator_put among others) have been removed from 0.9.6. You will need to stick with 0.9.5.3 and configure it appropriately" [4]

NOTE: "The latest release, 0.9.6.1, features support for PHP 5.3 and also works with PHP 5.1 and 5.2. The previous 0.9.5 branch supports PHP 4 and all PHP 5 releases including 5.2. In older releases, the encoder will only work with PHP versions from the 4.x.x branch." [5]

PHP eAccelerator on SourceForge - http://sourceforge.net/projects/eaccelerator/


yum install php53-devel gcc make

wget http://downloads.sourceforge.net/project/eaccelerator/eaccelerator/eAccelerator%200.9.6.1/eaccelerator-0.9.6.1.zip
unzip eaccelerator-0.9.6.1.zip
cd eaccelerator-0.9.6.1

phpize

# see fix http://www.vbseo.com/blogs/danny-bembibre/enable-caching-functions-get-put-eaccelerator-45/  (works only on on 0.9.5.*)
./configure \
   --enable-eaccelerator=shared \
   --with-php-config=/usr/bin/php-config \
   --with-eaccelerator-shared-memory

make clean && make

sudo make install
# Installing shared extensions:     /usr/lib/php/modules/

# cp eaccelerator.ini /etc/php.d/
cat > /etc/php.d/eaccelerator.ini <<EOF
extension="eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
EOF


# test:
echo "<?php phpinfo(); ?>" | php | grep "eAccelerator support"
# eAccelerator support => enabled
echo "<?php var_dump(function_exists('eaccelerator_get')); ?>" | php
# bool(true)

# test
cat > test.php <<EOF
<?php
$rfunc = get_extension_funcs( 'eaccelerator' );
print_r($rfunc);
 
function ea ($str)
{
        eaccelerator_put("testkey", $str);
        for ($i = 0; $i < 1e5; $i++)
        {
                $r = eaccelerator_get("testkey");
        }
        return $r;
}
 
$str = str_repeat("1234567890", 1024); // 10 KB
$r = ea($str);
echo strlen($r);
?> 
EOF
php test.php
# should list functions (especially _get and _put) and output '1024'

MediaWiki Failes to Detect eAccelerator

The PHP eAccelerator will make the MediaWiki faster, but MediaWiki will not be able to detect it for it's own seperate caching purposes:

"eAccelerator caches php bytecode to speed its execution. The scripts don't need to do anything special about it, so if you have eAccelerator working, it will speed up MediaWiki even if MediaWiki is not aware of it.
MediaWiki detects eAccelerator in order to use it for caching its own data. That's the bit that is disabled if MediaWiki can't find it. The issue is, mediawiki detects it by checking for the existance of eaccelerator_get(). Since it would need to call that function in order to use it for caching, it can't use it if php doesn't recognise that function. What's the output of var_dump(function_exists('eaccelerator_get')); on a single php file?
If it works there, there's something scary for mediawiki not detecting it. If it reports the function doesn't exist, you should probably ask to eAccelerator guys about it." [6]

Which returns: bool(false)

"These functions have been disabled by default. You should enable them with the configure command. Look at configure --help for the right options. These functions have been disabled because when leaving them on without any precautions these functions can be used for a local DoS attack by keep putting data in shared memory. " [7]
"Having to enable them at configure time is not too user friendly, a configuration option at global php.ini would have been people preferable for people like Peter installing from packages.
It may be interesting to have the MediaWiki installer detect eAccelerator built without --with-eaccelerator-shared-memory to provide a more accurate message. " [8]

APC

PHP: Installation - Manual - http://www.php.net/manual/en/apc.installation.php [9]

sudo yum install php-pear pcre-devel
sudo pecl install apc
echo "extension=apc.so" > /etc/php.d/apc.ini << EOF
extension=apc.so
apc.enabled=1
EOF

# test - not sure why the first is false?  builtin?
echo "<?php phpinfo(); ?>" | php | grep "APC Support"
# APC Support => disabled
echo "<?php phpinfo(); ?>" | php | grep "apc.enabled"
# apc.enabled => On => On

Testing:

/www/notes/includes/installer/Installer.php
        protected $objectCaches = array(
                'xcache' => 'xcache_get',
                'apc' => 'apc_fetch',
                'eaccel' => 'eaccelerator_get',
                'wincache' => 'wincache_ucache_get'
        );

echo "<?php print_r(get_extension_funcs('eaccelerator')); ?>" | php | grep eaccelerator_get

echo "<?php print_r(get_extension_funcs('apc')); ?>" | php | grep apc_fetch
#     [4] => apc_fetch

echo "<?php var_dump(function_exists('apc_fetch')); ?>" | php 

Statistics: use the apc.php script [10] [11]

cp /usr/share/pear/apc.php /www

Tree Options

Search for Three Letter Words

"By default MediaWiki uses MySQL and the default FULLTEXT indexing uses built-in stop words and a minimum word length of four. A list of the stop words is available but are the usual thing (the, and, one_, etc.). You can set your own stop words by setting the ft_stopword_file system variable but the default stop words may be sufficient to your purposes. However, there are many three letter words which you may like to index (_SVN, RSS, FAQ, etc.). In order to do this you need to change the FULLTEXT indexing to a minimum word length of three. To do this edit the my.ini and add to the end of the [mysqld] section:" [12]

[mysqld]

# Minimum word length to be indexed by the full text search index.
# You might wish to decrease it if you need to search for shorter words.
# Note that you need to rebuild your FULLTEXT index, after you have
# modified this value.
ft_min_word_len = 3

"Restart MySQL, and then reindex the relevant tables. The tables are ${mw_}searchindex where ${mw_} is the table prefix for the MediaWiki instance (there will be one searchindex table for each instance). To reindex the table, log into the server and start up MySQL Administrator. Log in as root and click Catalogs, then wikidb. Select the table and click the Maintenance button. Select Repair Tables and press Next. Check the Quick option under Repair Method and click Repair Tables. Repeat for each MediaWiki instance." [13]

Reindex table:

use [database];
ANALYZE TABLE searchindex;
REPAIR TABLE searchindex;
OPTIMIZE TABLE searchindex;


Removing default search limitations in MediaWiki and MySQL « Delirious Development Dialysis - http://leefw.wordpress.com/2008/03/05/getting-past-default-searching-limitations-in-mediawiki-and-mysql/

Editing the MediaWiki configuration. Locate the LocalSettings.php file in your MediaWiki installation directory, usually a subdirectory of your web server’s document root, say /htdocs on Apache. Edit the file and add the variable wgDBminWordLen to it. Set it’s value to 3, so:

   $wgDBminWordLen = 3;
REPAIR TABLE searchindex QUICK;

Subpages

"subpages are pages separated with a "/" (a slash) from their 'parent' page. Making a new [[link]] that begins with a / (slash) is the common way to start a subpage. The page to which this link points is considered "subordinate" to its host page, and is titled and linked as [[Parentpage/Subpage]]. It is possible to create a subpage of a subpage (or a sub-subpage). At the top of each subpage or sub-subpage, you can find a backlink (a.k.a. breadcrumb) to the higher levels of the page." [14]

Wikipedia:Subpages - Wikipedia - http://en.wikipedia.org/wiki/Wikipedia:Subpages