MediaWiki

From GeilThings

Jump to: navigation, search
MediaWiki
MediaWiki-notext.svg
General
Version 1.21.1
Stable 1.21.1
Function Wiki Software
Scripts

Contents

General

Wikidata

About the Wikidata project: http://meta.wikimedia.org/wiki/New_Wikidata

Extensions

Skins

Other

cd /path/tp/mediawiki
mkdir sitemap
php maintenance/generateSitemap.php --fspath sitemap --urlpath http://wiki.geilthings.com/sitemap --server http://wiki.geilthings.com --compress no
 
# Execute it as a cron job once a day.
 
crontab -e
0 0 * * * php /path/to/wiki/maintenance/generateSitemap.php --fspath /path/to/wiki/sitemap --urlpath http://www.geilthings.com/sitemap --server http://www.geilthings.com --compress no

Installing MediaWiki

NEWVERSION=1.18.1
MAINVERSION=1.18
# PATHTOWIKI: No trailing slash.
# e.g. /var/www/html/wiki
PATHTOWIKI=/path/to/wiki
 
cd /opt
wget http://download.wikimedia.org/mediawiki/${MAINVERSION}/mediawiki-${NEWVERSION}.tar.gz
tar xvzf mediawiki-${NEWVERSION}.tar.gz
rm -f mediawiki-${NEWVERSION}.tar.gz
mv mediawiki-${NEWVERSION} ${PATHTOWIKI}
chown -R apache. ${PATHTOWIKI}
 
mysql -u adminuser adminuserpassword
create database mwdatabase;
grant index, create, select, insert, update, delete, alter, lock tables on mwdatabase.* to 'mwuser'@'localhost' identified by 'mwuserpassword';
commit;
quit;
 
# Image processing.
yum install ImageMagick gd
 
# PHP accelerator.
yum install php-devel php-pear pcre-devel
pecl install apc
# Defaults were accepted
 
cd /etc/php.d/
vi apc.ini
i
#add
extension=apc.so
# Press Esc Key.
:w
:q
httpd -k restart
 
# For Unicode normalization.
yum install php-intl
 
# Upload directory:
# From http://www.mediawiki.org/wiki/Manual:Security#Upload_security
# Add the following to the httpd virtual host conf file:
<Directory "/path/to/wiki/images">
    # 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.
</Directory>
 
# Point the browser to the mediawiki site and follow the instructions.
# ...
 
# Environmental Checks Warnings I could not get rid of:
# GNU diff3 not found.
# Could not find GD library or ImageMagick.
# Warning: The installed version of the Unicode normalization wrapper uses an older version of the ICU project's library.

Some Warnings encountered during Installation and solutions:

1. Could not find GD library or ImageMagick.

# To create thumbnails (from .svg files): Install ImageMagick
yum install ImageMagick
# 23 other dependencies were installed (CentOS 6.2). Wow.
 
yum install gd
 
# However the warning did not disappear.

2. No PHP accelerator installed.

# Install APC.
# APC: Alternative PHP Cache - http://us.php.net/manual/en/book.apc.php
# php extension to speed-up the performance of php.
# I did not have another php accelerator installed, so I did not have to deal with problems arising from two accelerators
 
yum install php-devel
yum install php-pear
# Now you can run pecl (PHP Extension Community Library, similar to PEAR, gets installed with the php-pear package)
pecl install apc
# Defaults were accepted
# make fails with error:
# In file included from /var/tmp/APC/apc.c:44:
# /usr/include/php/ext/pcre/php_pcre.h:29:18: error: pcre.h: No such file or directory
 
# According to
# http://stackoverflow.com/questions/4720666/sudo-pecl-install-apc-returns-error
# solution is to install pcre-devel
 
yum install pcre-devel
 
pecl install apc
 
# Now it ends successfully with
# install ok: channel://pecl.php.net/APC-3.1.9
# You should add "extension=apc.so" to php.ini
 
# However, in php.ini file it says:
#; Note: packaged extension modules are now loaded via the .ini files
#; found in the directory /etc/php.d; these are loaded by default.
 
cd /etc/php.d/
vi apc.ini
#add
extension=apc.so
 
httpd -k restart
 
# apc appears now in phpinfo() as loaded module.

3. Upload directory unsecure.

# Upload directory:
# Warning: Your default directory for uploads /var/www/html/w_wiki/images/ is vulnerable to arbitrary scripts execution.
# The warning dissapeared after adding the suggested code from 
# http://www.mediawiki.org/wiki/Manual:Security#Upload_security
# to the httpd virtual host conf file.

4. Diff3.

  • It reports that diff3 is not installed, however it is (try 'diff3' on the command line, diff3 is part of the diffutils package that can be installed via yum).
  • Path is /usr/bin/diff3
  • No solution here.

Running MediaWiki

  • Read the FAQ (http://www.mediawiki.org/wiki/Manual:FAQ) to see the many options, how to configure MediaWiki.
  • Error 500 while trying to import other mediawiki's pages.
    • Error in the httpd log file: PHP Fatal error: Class 'XMLReader' not found in ...includes/Import.php on line ..., referer: .../wiki/Special:Import
    • Solution: yum install php-xml, httpd -k restart
  • While uploading a .svg file:
    • Error creating thumbnail: sh: wmf2eps: command not found
    • convert: Delegate failed `"wmf2eps" -o "%o" "%i"' @ delegate.c/InvokeDelegate/1032.
    • convert: unable to open image
    • Solution: yum install libwmf (it contains wmf2eps). Restart httpd.
  • While uploading a .svg file:
    • Error creating thumbnail: ERROR: meta.c (179): wmf_header_read: this isn't a wmf file
    • convert: Delegate failed `"wmf2eps" -o "%o" "%i"'
    • Solution: Add to LocalSettings.php: $wgSVGConverter = 'rsvg'; restart httpd.
  • Change the relative URL path to the logo, otherwise it will be overwritten while upgrading.
    • In LocalSettings.php, look for $wgLogo

Upgrade MediaWiki


######### START EDIT #########
 
APPNAME=mediawiki
DATABASENAME=databasename
MYSQLADMINUSER=root
MYSQLADMINUSERPWD=supermegahypersecreto
# PATHTOWIKI: No trailing slash, e.g. /var/www/html/wiki
PATHTOWIKI=/path/to/wiki
# The directory where I want to download the .zip files from the MediaWiki site.
DOWNLOADDIRECTORY=/opt
# If I want to backup the whole site, set it to TRUE.
ISBACKUP=TRUE
# BACKUPROOTDIR is only relevant if ISBACKUP=TRUE
BACKUPROOTDIR=/home/backup
DATE=`date +%Y-%m-%d`
 
######### END OF EDIT #########
 
cd ${PATHTOWIKI}
MAXMAJORVERSIONNUMBER=0
for file in RELEASE-NOTES-*
do
  # Determine which file has the greatest version number.
  MAJORVERSIONNUMBER=`echo "$file" | awk -F"NOTES-" '{print $2}'`
  # echo $MAJORVERSIONNUMBER
  if [[ $MAXMAJORVERSIONNUMBER < $MAJORVERSIONNUMBER ]]; then 
    MAXMAJORVERSIONNUMBER=$MAJORVERSIONNUMBER
  fi
done
# Now we know the file name
# containing the current installed version:
# RELEASE-NOTES-${MAXMAJORVERSIONNUMBER}
OLDVERSION=`sed '6!d' ${PATHTOWIKI}/RELEASE-NOTES-${MAXMAJORVERSIONNUMBER} | grep -Po '^.*?\K(?<=== MediaWiki ).*?(?= )'`
echo $OLDVERSION
 
RAWNEWVERSION=`curl -sd "action=ask&query=[[MediaWiki]]|%3FStable&format=json" http://www.geilthings.com/api.php`
# Get Version as Substring. 
# Using grep to sed to extract STRING between first occurrence of MATCH1 and next occurrence of MATCH2: 
# http://bit.ly/Ucsnb9 
NEWVERSION=`echo "$RAWNEWVERSION" | grep -Po '^.*?\K(?<=Stable\":\[\").*?(?=\")'`
# Test.
echo $NEWVERSION
 
NEWVERSION1=`echo "$NEWVERSION" | grep -Po '^.*?\K(?<=^).*?(?=\.)'`
NEWVERSION2=`echo "$NEWVERSION" | grep -Po '^.*?\K(?<=\.).*?(?=\.)'`
MAINVERSION=$NEWVERSION1.$NEWVERSION2
echo $MAINVERSION
 
# Backup.
if [[ ${ISBACKUP} == "TRUE" ]]; then
  # The script breaks if variable names are not enclosed with {}
  BACKUPDIR=${BACKUPROOTDIR}/${APPNAME}/${APPNAME}_${OLDVERSION}_${DATE}
  echo $BACKUPDIR
 
  # Create backup directory if it does not exist.
  if [ ! -d "${BACKUPDIR}" ]
  then
    mkdir -m 755 -p ${BACKUPDIR}
  fi
 
  # Minimal: Backup configuration and files that are usually changed.
  # cp -p ${PATHTOWIKI}/LocalSettings.php $BACKUPDIR/LocalSettings.php
  # cp -p ${PATHTOWIKI}/robots.txt $BACKUPDIR/robots.txt
  # cp -p ${PATHTOWIKI}/favicon.ico $BACKUPDIR/favicon.ico
 
  cp -rp ${PATHTOWIKI} $BACKUPDIR
  # Backup database.
  mysqldump -u ${MYSQLADMINUSER} -p${MYSQLADMINUSERPWD} --add-drop-table ${DATABASENAME} >> $BACKUPDIR/${APPNAME}_${OLDVERSION}_${DATE}.sql
fi
 
cd ${DOWNLOADDIRECTORY}
# Get the file
wget http://download.wikimedia.org/mediawiki/${MAINVERSION}/mediawiki-${NEWVERSION}.tar.gz
 
# Strip the leading component of the file name while decompressing 
# (e.g. mediawiki-1.18.0) with --strip-components.
tar xvzf mediawiki-${NEWVERSION}.tar.gz -C ${PATHTOWIKI}/ --strip-components=1
 
# Read release Notes.
cd ${PATHTOWIKI}
vi RELEASE-NOTES-${MAINVERSION}
:q
 
# Read upgrade Notes.
cd ${PATHTOWIKI}
vi UPGRADE
:q
 
# Read history Notes.
cd ${PATHTOWIKI}
vi HISTORY
:q
 
cd ${PATHTOWIKI}/maintenance
php update.php
 
# In MediaWiki 1.19 file upload stopped working with error messages:
# In the file upload page:
# Could not open lock file for ...
# In the httpd .log file:
# PHP Warning:  wfMkdirParents: failed to mkdir
# Solution:
chown -R apache. ${PATHTOWIKI}/images
 
# Just in case.
httpd -k restart
 
# Test it. 
# Refresh the browser; some changes (e.g. those involving jQuery) will only be active
# after reloading the current jQuery library.
# I created a page, "Test MediaWiki Extensions" with particular extensions running on it.

Issues

wfLoadExtensionMessages()

After upgrading to MediaWiki 1.21.1, the error appears for some extensions: PHP Fatal error: Call to undefined function wfLoadExtensionMessages(). According to http://bit.ly/12iakAM, wfLoadExtensionMessages() was deprecated in 1.16 and removed during the development of 1.21. Solution: Remove or comment the calls to the function in the affected extension.

Versions

Software name Version number Version date
MediaWiki 1.20.1
1.20.2
1.20.3
1.20.4
1.21.1
1 December 2012
8 December 2012
4 March 2013
27 April 2013
22 June 2013

Comments

blog comments powered by Disqus