MediaWiki

Installation

The MediaWiki web site has an installation guide specifically for FreeBSD under “System-specific instructions” (http://www.mediawiki.org/wiki/Manual:Running_MediaWiki_on_FreeBSD). Read and follow this article. The following contains a summary of the steps involved.

  1. Install Apache, PHP, MySQL, and MediaWiki Using Packages:
    pkg_add -r apache22 mysql-server php5 php5-mysql mediawiki
    pkg_add -r php5-ctype #ParserFunctions extension for template logic
    pkg_add -r tidy #correct garbage HTML tags
    pkg_add -r inkscape #allow SVG upload and to enable thumbnail and preview rendering with Inkscape
    pkg_add -r php5-xmlreader #extract meta data from SVG files using the XMLReader PHP extension
    pkg_add -r ocaml ImageMagick ghostscript8 teTeX #TeX support

    Compile texvc:

    cd /usr/local/www/mediawiki/math/
    gmake

    Reinstall php5 to include mod-php:

    cd /usr/ports/lang/php5
    make config
    make
    make deinstall
    make reinstall

    During the make config step above, enable the “APACHE” option in the menu.

  2. Further configuration of PHP Some parameters of the wiki, such as maximum upload size and maximum PHP execution time must be set in PHP itself. Edit (or create) the file /usr/local/etc/php.ini:
    upload_max_filesize = 500M
    post_max_size = 500M
    session.save_path = "/var/lib/phpsess"
    max_execution_time = 600

    The temporary directory for PHP sessions, /var/lib/phpsess in this sample setup, should be owned by user www and have permissions 733. When you make changes to php.ini, you have to restart Apache for the changes to take effect:

    apachectl restart
  3. Set up MySQL
    • Check if the database server is running:
    mysqladmin status

    If it is not run mysqld_safe to start it:

    /mysqld_safe &

    Another way to start initially the MySQL server is to run the configure script available at the root of the installation. It creates the initial tables and automatically starts the mysql daemon

    • Set a password for the “root” account on your database server:
    mysqladmin -u root password new_root_password
    history -c
    • Run the MySQL command-line client:
    mysql -u root -p

    This will prompt for the “root” database password you just set, then connect to the MySQL server. Now, continue with the SQL commands below:

    create database group_wiki;
    grant index, create, select, insert, update, delete, alter, lock tables on group_wiki.* to 'wikiuser'@'localhost' identified by 'new_wikiuser_password';
    flush privileges;
    exit

    Start mysql-server:

    /usr/local/etc/rc.d/mysql-server onestart
  4. Set up Apache Add the following sections to /usr/local/etc/apache22/httpd.conf:
    LoadModule php5_module libexec/apache/libphp5.so
    
    <IfModule php5_module>
      DirectoryIndex index.php index.html
      AddType application/x-httpd-php .php
      AddType application/x-httpd-php-source .phps
    </IfModule>

    If you want to serve MediaWiki content exclusively, you can simply change the Apache document root to the MediaWiki installation directory:

    DocumentRoot "/usr/local/www/mediawiki"

    Also add an entry for the MediaWiki directory to httpd.conf:

    <Directory "/usr/local/www/mediawiki">
      Options Indexes FollowSymLinks
      DirectoryIndex index.php index.html
      AllowOverride None
      Order allow,deny
      Allow from all
    </Directory>

    Restart Apache:

    apachectl restart
  5. Edit /etc/rc.conf Make sure your hostname in rc.conf contains a domain name, and that Apache and MySQL are set to start automatically during boot:
    hostname="server.dept.univ.edu"
    apache22_enable="YES"
    mysql_enable="YES"
  6. Run the MediaWiki web installer Create the images directory for storing uploads if it does not exist yet:
    mkdir mediawiki/images

    Make sure all MediaWiki files belong to user www:

    chown -R www mediawiki

    Open http://localhost/mediawiki/mw-config/index.php in your browser to start installation. Enter root and your MySQL root password in the superuser name and password fields. After the installer has finished successfully, copy the resulting LocalSettings.php file to the MediaWiki root directory.

  7. Edit /usr/local/www/mediawiki/LocalSettings.php Change the relevant variables:
    $wgSitename, $wgMetaNamespace = "Siepmann Group Wiki";
    $wgLogo = "$wgScriptPath/where_the_logo_is.gif";
    $wgEmergencyContact, $wgPasswordSender = "group@email.com";
    $wgDBname = "group_wiki";
    $wgDBuser = "wikiadmin";
    $wgDBpassword = "password";
    $wgDBadminuser = "wikiadmin";
    $wgDBadminpassword = "password";
    $wgEnableUploads = true;
    
    # User-added options
    $wgUseTidy = true;
    $wgFileExtensions = array_merge($wgFileExtensions, array('svg','tar','tar.gz','tgz','tar.bz2','tbz','tar.Z','tex','pdf','pptx','ppt','docx','doc','xlsx','xls','f','F','for','FOR','fpp','FPP','f90','F90','f95','F95','c','cpp','cxx','cc'));
    $wgSVGConverters = array('Inkscape' => '/usr/local/bin/inkscape -z -w $width -f $input -e $output',);
    $wgSVGConverter = 'Inkscape';
    putenv("PATH=".getenv("PATH").":/usr/local/bin");
    $wgUseTeX = true;
    $wgJobRunRate = 0;
    $wgExternalLinkTarget = '_blank';
    $wgMimeTypeBlacklist = array(
       # HTML may contain cookie-stealing JavaScript and web bugs
       'text/html', 'text/javascript', 'text/x-javascript',  'application/x-shellscript',
       # PHP scripts may execute arbitrary code on the server
       'application/x-php', 'text/x-php',
       # Other types that may be interpreted by some servers
       'text/x-python', 'text/x-perl', 'text/x-bash', 'text/x-sh', 'text/x-csh',
       # Client-side hazards on Internet Explorer
       'text/scriptlet', 'application/x-msdownload',
       # Windows metafile, client-side vulnerability on some systems
       'application/x-msmetafile',
       # A ZIP file may be a valid Java archive containing an applet which exploits the
       # same-origin policy to steal cookies
       'application/zip',
       # MS Office OpenXML and other Open Package Conventions files are zip files
       # and thus blacklisted just as other zip files. If you remove these entries
       # from the blacklist in your local configuration, a malicious file upload
       # will be able to compromise the wiki's user accounts, and the user
       # accounts of any other website in the same cookie domain.
       #'application/x-opc+zip',
       #'application/msword',
       #'application/vnd.ms-powerpoint',
       #'application/vnd.msexcel',
    );
  8. Install extensions
    • wikEd (or CKEditor): add the complete version of the installation code to the MediaWiki:Common.js page.
    // install [[Wikipedia:User:Cacycle/wikEd]] in-browser text editor
    importScriptURI('//en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js'
    + '&action=raw&ctype=text/javascript');
    • GeSHi: download and extract it to the extensions directory.
    • GeSHiCodeTag: create a new file in the extensions directory called GeshiCodeTag.php which should contain the source code, replace the line:
    $languagesPath = "extensions/geshi/geshi";

    to

    $languagesPath = "$IP/extensions/geshi/geshi";

    in the file, and finally add the following line to LocalSettings.php.

    ## GeshiCodeTag extension
    require_once("$IP/extensions/GeshiCodeTag.php");
    • SyntaxHighlight GeSHi: download and extract it to the extensions directory, replace the line:
    require( 'geshi/geshi.php' );

    to

    require( '../geshi/geshi.php' );

    in SyntaxHighlight_GeSHi.class.php, and finally add the line:

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

    to LocalSettings.php.

Upgrade

Software files will be updated when updating FreeBSD (such as by portupgrade), but the database should be checked afterwards:

cd /usr/local/www/mediawiki/maintenance
php update.php

Certain extensions may need to be updated manually, and LocalSettings.php may also need to be adjusted as documented in the “configuration changes” section of the release notes. It may be necessary to place the database in read-only mode first which prevents user edits:

$wgReadOnly = 'System upgrading';

Backup

Remember to backup both the database and file system.

Comments

Comments powered by Disqus