Manual:Running MediaWiki on Gentoo Linux

Gentoo basics
Gentoo Linux uses the Portage package management system, invoked by the emerge command, to download, compile, and install software.

To minimize the chances of having connection problems when you emerge something, add multiple mirror sites to the file /etc/make.conf, as in the following example:

GENTOO_MIRRORS="ftp://ftp.heanet.ie/pub/gentoo/ http://ftp.easynet.nl/mirror/gentoo/"

The main website of the Gentoo distribution, Gentoo.org, maintains a list of possible mirrors (the ones used above are only for illustration purposes). You can also install the mirrorselect utility to assist in finding and enabling different mirror sites, so you don't have to edit /etc/make.conf yourself:

emerge mirrorselect

Note that every emerge command can be invoked with the --pretend and --verbose options (or -pv</tt> for short), so you can see what version of the software will be installed, which version if any is already installed, and what USE flags are recognized by the package. For example:

emerge -pv portage

To ensure you have the latest list of available packages, you can update your local copy of the software tree by issuing the command:

emerge --sync

In addition, when "emerging" a package, the options --update</tt> and --deep</tt> (-uD</tt> for short) can be used to install any updates for all the packages upon which the given package depends.

See the Portage documentation at Gentoo.org for more information on all of these aspects of using emerge</tt>, especially if you encounter an error when trying any of these commands.

You might also be interested in the functionality provided by ufed</tt> (the Gentoo Linux USE flags editor) or profuse</tt> (a more GUI-oriented USE flags editor), and gentoolkit</tt> (which contains equery</tt> and the essential Gentoo utility revdep-rebuild</tt>).

emerge ufed emerge profuse

(You only need one of the above.)

emerge gentoolkit

(Not MediaWiki specific, but essential for maintaining your Gentoo Linux distribution in good working order.)

USE flags and optional packages
As of MediaWiki 1.8.5, the following USE flags are supported:


 * imagemagick : Enables support for Imagemagick (image converter)
 * math       : Adds math rendering support
 * mysql      : Adds mySQL Database support
 * postgres   : Adds support for the postgresql database
 * restrict   : Initial setup will only allow sysop user to create new accounts, read and edit any pages
 * vhosts     : Adds support for installing web-based applications into a virtual-hosting environment

Use the imagemagick</tt> flag to enable thumbnail creation if you do not want to include support for the gd</tt> graphics library in php</tt> (see below). Enabling this USE flag will pull in the imagemagick</tt> package as a dynamic dependency when you install MediaWiki, but if you want to install it beforehand, use:

emerge -pv imagemagick emerge imagemagick

(Remember that the -pv</tt> option lists package version numbers and USE flags. This "preview" step will not be listed in the following instructions, but is always a good idea to do before emerging a package.)

If you want "math support" — i.e., proper interpretation and display of TeX/LaTeX code enclosed in &lt;math> tags — use the math</tt> USE flag. This will pull in the teTeX, Ghostscript, and ImageMagick packages automatically when you <tt>emerge</tt> the MediaWiki package. Otherwise, you can install them separately, using:

emerge tetex emerge ghostscript emerge imagemagick

Finally do: USE="ocamlopt" emerge dev-lang/ocaml

Required packages
Required packages are mysql, apache, and php:

emerge -uD mysql apache php

By default, some (if not all) php ebuilds disable sessions, which will break logins. Add sessions by appending 'session' to the mod_php USE line in /etc/portage/package.use (probably required):

USE="session" emerge -uD mod_php

Configure Apache
Start web server by /etc/init.d/apache2 start Stop it by /etc/init.d/apache2 stop After making changes to the Apache configuration files, you can quickly restart Apache by /etc/init.d/apache2 restart

To start Apache on the startup. rc-update add apache2 default

Add PHP Support
apache2 uses modules to dynamically load and unload extra functionalities. php support is one of them. There is no mod_php module in apache server after the default installation. We need to add mod_php into apache. Edit the configuration file of apache2

adding php support (step 1)
vi /etc/conf.d/apache2 APACHE2_OPTS="-D SSL -D PHP5" /etc/init.d/apache2 restart
 * 1) APACHE2_OPTS="-D SSL"

Gentoo automatically installs <tt>/etc/apache2/modules.d/70_mod_php.conf</tt> which contains the directives to load the module, as described in step 2. The <tt>-D PHP5</tt> is necessary to pass the <tt>IfDefine PHP5</tt> which wraps <tt>70_mod_php.conf</tt>.

(This is with <tt>net-www/apache-2.0.58-r2</tt>.)

adding php support (step 2)
vi /etc/apache2/conf/apache2.conf or  vi /etc/apache2/httpd.conf You will see module list in apache2.conf LoadModule access_module                modules/mod_access.so LoadModule auth_module                   modules/mod_auth.so LoadModule auth_anon_module              modules/mod_auth_anon.so LoadModule auth_dbm_module               modules/mod_auth_dbm.so or you can edit /etc/apache2/modules.d/*.conf, where *.conf is the name of the module ( ex: 70_mod_php5.conf )

Add mod_php into it by one more line: LoadModule php5_module   modules/libphp5.so Consequently add .php file name handling capability by adding AddType application/x-httpd-php .php AddType application/x-httpd-php .phtml AddType application/x-httpd-php .php3 AddType application/x-httpd-php .php4 AddType application/x-httpd-php .php5 AddType application/x-httpd-php-source .phps save apache2.conf and restart apache server apache2ctl restart or /etc/init.d/apache2 restart We now have an apache server with php support.

Configure MySQL
Refer to MySQL config for details

Initialize the mysql database ebuild /var/db/pkg/dev-db/mysql-VERSION/mysql-VERSION.ebuild config Start the server /etc/init.d/mysql start Choose a password: /usr/bin/mysqladmin -u root password 'PASSWORD' Test it mysqlshow -p

Let it run automatically each time your machine is powered up rc-update add mysql default

Get Mediawiki
Run the following command to install mediawiki, being sure to install an Gentoo mediawiki ebuild which is as close as possible to current mediawiki :

emerge mediawiki

Unpack

 * This step is only necessary if you are installing a new version, and you are sure that emerge hasn't already copied the files into place. In the case of a first time install, this should not be necessary.

diff -r /var/www/localhost/htdocs/mediawiki/ # see if there are any differences. cp -rvfp /var/www/localhost/htdocs/mediawiki/ /var/www/localhost/htdocs/mediawiki.dist # back up the dist mediawiki www root cp -rfv /usr/share/webapps/mediawiki/{version...}/htdocs /var/www/localhost/htdocs/mediawiki # copy files from the mediawiki distro as an overlay onto the dist mediawiki www root (unsafe?)

Set permissions
user should be apache, group should be apache.

chown -R apache:apache <PATH_TO_MEDIAWIKI_DIRECTORY>

You should not give anybody access to this directory.. or at least LocalSettings.conf as it contains passwords! Just let user apache do it.

Mediawiki 1.3.2 needs to write config directory during initialization. Now, we use /var/www/localhost/htdocs/mediawiki cd /var/www/localhost/htdocs/mediawiki chmod a+w config

Alias directory
edit your /etc/apache2/conf/commonapache2.conf file or /etc/apache2/httpd.conf

You do NOT want mediawiki in a world readable directory, when php isn't running, so this is useful: (this is using apache2, so the php4 module is called sapi_apache2.c ) <IfModule sapi_apache2.c>   Alias /mediawiki/ /var/www/localhost/mediawiki-1.3.3/ Alias /mediawiki /var/www/localhost/mediawiki-1.3.3 Alias /wiki_persistant/ /var/www/localhost/wiki_persistant/ Alias /wiki_persistant /var/www/localhost/wiki_persistant

<Directory /var/www/localhost/wiki_persistant/> Order deny,allow Allow from all </Directory>

<Directory /var/www/localhost/mediawiki-1.3.3/> Options +includes Order deny,allow Allow from all </Directory> </IfModule>
 * 1)      AllowOverride All

Setup RewriteRules
I have no idea how to do these, see Manual:Short URL

This is what I used:

RewriteRule ^/mediawiki/  - [L]