Katlas installation notes: Difference between revisions

From Knot Atlas
Jump to navigationJump to search
No edit summary
 
m (Reverted edits by LapasOrsit (Talk); changed back to last version by Drorbn)
 
(139 intermediate revisions by 14 users not shown)
Line 1: Line 1:
On July 14, 2007 we've upgraded MediaWiki to version 1.10.1. The pre-upgrade installation notes are at [[MediaWiki 1.4 installation notes]].
Okay... these are my notes while trying to setup [http://katlas.math.toronto.edu/wiki/ the wiki on katlas].


==Upgrading MySQL==
===Fixing search===
In file <tt>/www/html/w/skins/MonoBook.php</tt> change <tt>&lt;form ... id="searchform"&gt;</tt> to <tt>&lt;form method=post ... id="searchform"&gt;</tt>.
For better or worse, I decided to upgrade MySQL to version 4.0 before doing anything else. I mostly followed [http://dev.mysql.com/doc/mysql/en/linux-rpm.html these instructions].


===Rendering PNG===
For this I need three RPMs which are all available with only a little digging at [http://www.mysql.com/ mysql.com]
Follow the instructions at http://mywiki.ncsa.uiuc.edu/wiki/MediaWiki_Servers#Problems_Rendering_PNG_Images:
* MySQL-shared-compat-4.0.25-0.i386.rpm
*Add to LocalSettings.php
* MySQL-server-4.0.25-0.i386.rpm
<pre>
* MySQL-client-4.0.25-0.i386.rpm
$wgMimeDetectorCommand = "file -bi";
</pre>
*then rebuild images
<pre>
# cd /www/html/w/maintenance
# php rebuildImages.php
Processing image...
Finished image... 3 of 4 rows updated
Processing oldimage...
Finished oldimage... 2 of 2 rows updated
#
</pre>


===Creating nice thumbnails with ImageMagick===
The first of these is required so we don't break dependencies while upgrading. Install it first, with
Unfortunately, they've broken things in mediawiki 1.10, and creating thumbnails of transparent gifs is horrible. If you make the following changes to /includes/media/Bitmap.php, things should behave just like in mediawiki 1.4 (i.e. perfectly, for our purposes).
:rpm -iv MySQL-shared-compat-4.0.25-0.i386.rpm
<pre>
Then upgrade the other two packages
// replacing this all with something much simpler from around mediawiki 1.4
:rpm -U MySQL-server-4.0.25-0.i386.rpm
# $cmd = wfEscapeShellArg($wgImageMagickConvertCommand) .
:rpm -U MySQL-client-4.0.25-0.i386.rpm
# " {$quality} -background white -size {$physicalWidth} ".
# wfEscapeShellArg($srcPath) .
# // Coalesce is needed to scale animated GIFs properly (bug 1017).
# ' -coalesce ' .
# // For the -resize option a "!" is needed to force exact size,
# // or ImageMagick may decide your ratio is wrong and slice off
# // a pixel.
# " -thumbnail " . wfEscapeShellArg( "{$physicalWidth}x{$physicalHeight}!" ) .
# " -depth 8 $sharpen " .
# wfEscapeShellArg($dstPath) . " 2>&1";
// here's what we used to do, back in mediawiki 1.4, and it works great.
$cmd = wfEscapeShellArg($wgImageMagickConvertCommand) .
" {$quality} -background white -geometry {$physicalWidth} ".
wfEscapeShellArg($srcPath) . " " .
wfEscapeShellArg($dstPath) . " 2>&1";
</pre>


===Modifying the navigation box===
Note the warning the server install gives --
Edit [[MediaWiki:Sidebar]].

===Add "tour" sidebar box===
In skins/MonoBook.php, right above the lines
<?php
if( $this->data['language_urls'] ) { ?>
add lines as follows:<pre><nowiki>
<div class="portlet" id="p-tour">
<h5><a href="/wiki/Tour_of_the_Knot_Atlas">tour</a></h5>
<div class="pBody">
<ul>
<li><a href="/wiki/5_2">5 2</a> (edit me!)
<li><a href="/wiki/5_2_Quantum_Invariants">5 2 Quantum Invariants</a>
<li><a href="/wiki/L10n85">L10n85</a>
<li><a href="/wiki/The_Multivariable_Alexander_Polynomial">Multivariable Alexander</a>
<li><a href="/wiki/Knot_Atlas:About">About</a>
<li><a href="/wiki/Data:5_2/Bridge_Index">Data:5_2/Bridge_Index</a>
<li><a href="/wiki/The_Mathematica_Package_KnotTheory%60">Knot Theory`</a>
<li><a href="/wiki/How_to_Edit_this_Manual...">How to Edit Manual...</a>
<li><a href="/wiki/Modifying_Knot_Pages">Modifying Knot Pages</a>
<li><a href="/wiki/Special:Recentchanges">Recent changes</a>
<li><a href="/wiki/To_Do">To Do</a> (history!)
</ul>
</div>
</div>
</nowiki></pre>

==="Redraw Page" tab===

Add to [[MediaWiki:Monobook.js]], following [http://en.wikipedia.org/wiki/Wikipedia:WikiProject_User_scripts/Scripts/Add_purge_to_tabs Wikipedia:WikiProject User scripts/Scripts/Add purge to tabs]:

addOnloadHook(function () {
var hist; var url;
if (!(hist = document.getElementById('ca-history') )) return;
if (!(url = hist.getElementsByTagName('a')[0] )) return;
if (!(url = url.href )) return;
addPortletLink('p-cactions', url.replace(/([?&]action=)history([&#]|$)/, '$1purge$2'),
'redraw page', 'ca-purge', 'Purge server cache for this page', '0');
});

===Spam filtering===
Follow the directions at http://www.mediawiki.org/wiki/Extension:SpamBlacklist

===Tweaking the job queue===
Running jobs seems to slow everything down horribly. It's '''essential''' that you add
<pre>
<pre>
$wgJobRunRate = 0.01;
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h katlas.math.toronto.edu password 'new-password'
See the manual for more instructions.
</pre>
</pre>
to <code>LocalSettings.php</code>. It may prove necessary to add a cron job running <code>/w/maintenance/runJobs.php</code>, if the length of the job queue (see [[Special:Statistics]]) gets out of hand. This should only happen after edits to widely used templates.

In an attempt to stop the job queue from processing latex, Scott added a line to <code>includes/JobQueue.php</code>.
<pre>
$options = new ParserOptions;
// turning off math rendering while processing jobs, because it's a terrible idea.
$options->setUseTeX( false );
</pre>

===Installing ParserFunctions===
In order to use template-like parser functions, such as <code>{{#ifexist:<pagename>|<true>|<false>}}</code>, we need to enable the ParserFunctions extension, following the instructions at http://meta.wikimedia.org/wiki/ParserFunctions.

Download the files
* [http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/ParserFunctions/Expr.php Expr.php]
* [http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/ParserFunctions/ParserFunctions.php ParserFunctions.php]
* [http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/ParserFunctions/ParserFunctions.i18n.php ParserFunctions.i18n.php]
and then add a line to LocalSettings.php:
<pre>
require_once( "$IP/extensions/ParserFunctions/ParserFunctions.php" );
</pre>

===Installing a PHP cache===
Look at http://meta.wikimedia.org/wiki/PHP_caching_and_optimization.

# Install PEAR, by saving http://go-pear.org/ as <code>/home/wiki/pear/go-pear.php</code>, then running <code>php go-pear.php</code> and following the prompts
# Install APC, by running <code>/home/wiki/pear/bin/pecl install apc</code>
# Add <code>extension=apc.so</code> to <code>/etc/php.ini</code>

You can see APC's statistics at http://katlas.org/apc.php

Add
<pre>
# See http://www.mediawiki.org/wiki/Manual:%24wgMainCacheType
$wgMainCacheType = CACHE_ACCEL;
</pre>
to <code>LocalSettings.php</code>.

===Installing memcached===
In my continuing quest for faster page loads, I'm trying memcached. Follow the nice instructions at http://blog.ajohnstone.com/archives/installing-memcached/.

Although it's not installed, it's not running, or being used. See http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/docs/memcached.txt?view=markup for instructions for actually running it. You'll probably need to uncomment some lines in LocalSettings.php too.


===Updating CSS and JS===
(note however that you need to upgrade the client package before mysqladmin is available to do this!)
* Write [http://en.wikipedia.org/wiki/MediaWiki:Common.css MediaWiki:Common.css] on top of the local [[MediaWiki:Common.css]].
* Write [http://en.wikipedia.org/wiki/MediaWiki:Monobook.css MediaWiki:Monobook.css] on top of the local [[MediaWiki:Monobook.css]].
* Write [http://en.wikipedia.org/wiki/MediaWiki:Common.js MediaWiki:Common.js] on top of the local [[MediaWiki:Common.js]] being super-careful not to step on any of our extensions.


===Increasing PHP's memory_limit===
I also deleted the local anonymous account, and put a password on the remote anonymous account. (Ask [[User:Scott]] for these passwords.)
In LocalSettings.php, change
ini_set( 'memory_limit', '20M' );
to
ini_set( 'memory_limit', '40M' );


===Fixing "Random Page"===
==Apache==
I had to fix the server name, from katlas to katlas.math.toronto.edu in httpd.conf


The standard MediaWiki [[Special:Random|random page]] algorithm is strange, and anyway unsuitable for our purposes. See [[Fixing "Random Page"]] for the details and for our fix.
I added
AllowOverride FileInfo
in the httpd.conf file, in the section for /var/www/html, so I could use .htaccess files to rewrite the wiki URLs nicely.

Latest revision as of 18:10, 8 January 2009

On July 14, 2007 we've upgraded MediaWiki to version 1.10.1. The pre-upgrade installation notes are at MediaWiki 1.4 installation notes.

Fixing search

In file /www/html/w/skins/MonoBook.php change <form ... id="searchform"> to <form method=post ... id="searchform">.

Rendering PNG

Follow the instructions at http://mywiki.ncsa.uiuc.edu/wiki/MediaWiki_Servers#Problems_Rendering_PNG_Images:

  • Add to LocalSettings.php
$wgMimeDetectorCommand = "file -bi"; 
  • then rebuild images
# cd /www/html/w/maintenance
# php rebuildImages.php 
Processing image...
Finished image... 3 of 4 rows updated
Processing oldimage...
Finished oldimage... 2 of 2 rows updated
#

Creating nice thumbnails with ImageMagick

Unfortunately, they've broken things in mediawiki 1.10, and creating thumbnails of transparent gifs is horrible. If you make the following changes to /includes/media/Bitmap.php, things should behave just like in mediawiki 1.4 (i.e. perfectly, for our purposes).

                        // replacing this all with something much simpler from around mediawiki 1.4
                        # $cmd  =  wfEscapeShellArg($wgImageMagickConvertCommand) .
                        #       " {$quality} -background white -size {$physicalWidth} ".
                        #       wfEscapeShellArg($srcPath) .
                        #       // Coalesce is needed to scale animated GIFs properly (bug 1017).
                        #       ' -coalesce ' .
                        #       // For the -resize option a "!" is needed to force exact size,
                        #       // or ImageMagick may decide your ratio is wrong and slice off
                        #       // a pixel.
                        #       " -thumbnail " . wfEscapeShellArg( "{$physicalWidth}x{$physicalHeight}!" ) .
                        #       " -depth 8 $sharpen " .
                        #       wfEscapeShellArg($dstPath) . " 2>&1";
                        // here's what we used to do, back in mediawiki 1.4, and it works great.
                        $cmd  =  wfEscapeShellArg($wgImageMagickConvertCommand) .
                                " {$quality} -background white -geometry {$physicalWidth} ".
                                wfEscapeShellArg($srcPath) . " " .
                                wfEscapeShellArg($dstPath) . " 2>&1";

Modifying the navigation box

Edit MediaWiki:Sidebar.

Add "tour" sidebar box

In skins/MonoBook.php, right above the lines

<?php
                if( $this->data['language_urls'] ) { ?>

add lines as follows:

        <div class="portlet" id="p-tour">
          <h5><a href="/wiki/Tour_of_the_Knot_Atlas">tour</a></h5>
          <div class="pBody">
            <ul>
            <li><a href="/wiki/5_2">5 2</a> (edit me!)
            <li><a href="/wiki/5_2_Quantum_Invariants">5 2 Quantum Invariants</a>
            <li><a href="/wiki/L10n85">L10n85</a>
            <li><a href="/wiki/The_Multivariable_Alexander_Polynomial">Multivariable Alexander</a>
            <li><a href="/wiki/Knot_Atlas:About">About</a>
            <li><a href="/wiki/Data:5_2/Bridge_Index">Data:5_2/Bridge_Index</a>
            <li><a href="/wiki/The_Mathematica_Package_KnotTheory%60">Knot Theory`</a>
            <li><a href="/wiki/How_to_Edit_this_Manual...">How to Edit Manual...</a>
            <li><a href="/wiki/Modifying_Knot_Pages">Modifying Knot Pages</a>
            <li><a href="/wiki/Special:Recentchanges">Recent changes</a>
            <li><a href="/wiki/To_Do">To Do</a> (history!)
            </ul>
          </div>
        </div>

"Redraw Page" tab

Add to MediaWiki:Monobook.js, following Wikipedia:WikiProject User scripts/Scripts/Add purge to tabs:

addOnloadHook(function () {
    var hist; var url;
    if (!(hist = document.getElementById('ca-history') )) return;
    if (!(url = hist.getElementsByTagName('a')[0] )) return;
    if (!(url = url.href )) return;
    addPortletLink('p-cactions', url.replace(/([?&]action=)history([&#]|$)/, '$1purge$2'),
                   'redraw page', 'ca-purge', 'Purge server cache for this page', '0');
});

Spam filtering

Follow the directions at http://www.mediawiki.org/wiki/Extension:SpamBlacklist

Tweaking the job queue

Running jobs seems to slow everything down horribly. It's essential that you add

$wgJobRunRate = 0.01;

to LocalSettings.php. It may prove necessary to add a cron job running /w/maintenance/runJobs.php, if the length of the job queue (see Special:Statistics) gets out of hand. This should only happen after edits to widely used templates.

In an attempt to stop the job queue from processing latex, Scott added a line to includes/JobQueue.php.

$options = new ParserOptions;
// turning off math rendering while processing jobs, because it's a terrible idea.
$options->setUseTeX( false );

Installing ParserFunctions

In order to use template-like parser functions, such as <false>, we need to enable the ParserFunctions extension, following the instructions at http://meta.wikimedia.org/wiki/ParserFunctions.

Download the files

and then add a line to LocalSettings.php:

require_once( "$IP/extensions/ParserFunctions/ParserFunctions.php" );

Installing a PHP cache

Look at http://meta.wikimedia.org/wiki/PHP_caching_and_optimization.

  1. Install PEAR, by saving http://go-pear.org/ as /home/wiki/pear/go-pear.php, then running php go-pear.php and following the prompts
  2. Install APC, by running /home/wiki/pear/bin/pecl install apc
  3. Add extension=apc.so to /etc/php.ini

You can see APC's statistics at http://katlas.org/apc.php

Add

# See http://www.mediawiki.org/wiki/Manual:%24wgMainCacheType
$wgMainCacheType = CACHE_ACCEL;

to LocalSettings.php.

Installing memcached

In my continuing quest for faster page loads, I'm trying memcached. Follow the nice instructions at http://blog.ajohnstone.com/archives/installing-memcached/.

Although it's not installed, it's not running, or being used. See http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/docs/memcached.txt?view=markup for instructions for actually running it. You'll probably need to uncomment some lines in LocalSettings.php too.

Updating CSS and JS

Increasing PHP's memory_limit

In LocalSettings.php, change

ini_set( 'memory_limit', '20M' );

to

ini_set( 'memory_limit', '40M' );

Fixing "Random Page"

The standard MediaWiki random page algorithm is strange, and anyway unsuitable for our purposes. See Fixing "Random Page" for the details and for our fix.