MediaWiki
From Gentoo Wiki
Resources
MediaWiki is a PHP-powered web application used by the Gentoo wiki and the various Wikimedia Project websites (including Wikipedia).
Installation
Prerequisites
- Install PHP. Enable the xmlreader USE flag, because MediaWiki requires it:
root #
echo "dev-lang/php xmlreader" >> /etc/portage/package.use
- Install a web server and set it up for use of PHP:
- Apache — an efficient, extensible web server. It is one of the most popular web servers used the Internet.
- Lighttpd — a fast and lightweight web server.
- Nginx — a robust, small, high performance web server and reverse proxy server.
- Install MySQL (MariaDB is a suitable alternative and the default virtual/mysql provider on Gentoo). Create a database for MediaWiki:
root #
mysql -u root -p
mysql> CREATE DATABASE IF NOT EXISTS `mediawiki` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`; mysql> CREATE USER 'mediawiki'@'localhost' IDENTIFIED BY 'changeme'; mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `mediawiki`.* TO 'mediawiki'@'localhost' IDENTIFIED BY 'changeme'; mysql> \q
- If the database (MariaDB or MySQL) server is on a different server than MediaWiki, set these USE flags:
www-apps/mediawiki mysql
dev-db/mariadb -backup -pam -perl -server
virtual/mysql -server
www-apps/mediawiki
USE flags for www-apps/mediawiki The MediaWiki wiki web application (as used on wikipedia.org)
+sqlite
|
Add support for sqlite - embedded sql database |
imagemagick
|
Enable optional support for the ImageMagick or GraphicsMagick image converter |
mysql
|
Add mySQL Database support |
postgres
|
Add support for the postgresql database |
vhosts
|
Add support for installing web-based applications into a virtual-hosting environment |
Install www-apps/mediawiki:
root #
emerge --ask www-apps/mediawiki
Setup
- Copy mediawiki files from /usr/share/webapps/mediawiki/{version}/htdocs to /var/www/localhost/htdocs/mediawiki
- Point a browser at http://127.0.0.1/mediawiki and follow the instructions.
- If there is no GUI on the computer running mediawiki, then log in from another machine using http://<server>/mediawiki instead, where <server> is the name or IP address of the server (see /etc/hosts).
- Page "Welcome to MediaWiki!":
- "Database name" is "mediawiki"
- "Database username" is "mediawiki"
- "Database password" is "changeme" (or what else is setup)
- Page "Connect to database":
- Database character set" should be "UTF-8"
- Page "Name"
- "Name of wiki" has to be set
- Setup admin user and password
- Page "Complete!"
- Download the LocalSettings.php configuration and move it to /var/www/localhost/htdocs/mediawiki/LocalSettings.php.
- Point a browser at http://127.0.0.1/mediawiki/ (or the address used above) to see the newly installed and configured wiki.
Advanced configuration
- To use a shorter URL make the following modifications:
add this somewhere (does not matter exactly where):
$wgArticlePath = "/wiki/$1";
$wgUsePathInfo = true;
and add this between <Directory> tags:
RewriteEngine On
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/mediawiki/index.php [L]
- By default the landing page in MediaWiki is unlocked for anyone to edit. Login as admin. By the top right of the page is an arrow that points down, click it and the 3rd option down is "protect" to lock down the page.
- Set an avatar for the wiki. Add to the bottom of /var/www/localhost/htdocs/mediawiki/LocalSettings.php:
$wgLogo = "/mediawiki/wiki.png";