Gentoo Wiki


This article is still a Stub. You can help Gentoo-Wiki by expanding it.



This guide will give instructions on setting up your own wiki, using mediawiki. Mediawiki is the framework used on the Gentoo-Wiki and Wikipedia. There are several other types of Wikis, several of which are listed at the end of this HOWTO. Take a look at them and make sure that MediaWiki suits your needs.

Installing Dependencies

There are a few things you will need before you can get your Wiki up and running -- a webserver, a database server, and PHP. We will use Apache for the web server && MySQL for the database.

Apache (Web Server)

For a more detailed installation reference, see the following:

Enable ssl support for Apache (you can disable it in config if you need to)

# echo "www-server/apache ssl" >> /etc/portage/package.use

Now install Apache

# emerge apache 

And I would highly recommend making a 5 minute investment to install mod_security for apache. It's silly not to make this miniscule effort, which will drastically improve security. You are exposing four very complex programs to every vandal, cracker, and spammer out there. Take the time to do it right, or your Wiki will just end up being full of advertisements for porn and pills, or worse(?) just deleted and your box rooted. Security rant over.

Install mod_security now:

# emerge mod_security

More details about mod_security.

Then download the Core Rules for ModSecurity from one of the following sources:

Now add the following to /etc/conf.d/apache2 to enable mod_security, ssl, and php

File: /etc/conf.d/apache2

PHP (Server Side Scripting Language)

MediaWiki requires PHP. If you want later install the ParserFunctions extension for MediaWiki, you will also need to enable the USE flag ctype. See PHP for installation instructions.

Configuring PHP

# echo "dev-lang/php suhosin" >> /etc/portage/package.use
# emerge -av php

If you want to use shared memory caching, read the memcached.txt from MediaWiki cvs.

MySQL (Database Server)

For a more detailed installation reference see:

  • point them to a postgresql guide

Install the mysql database,

# emerge -av mysql

Then run the configuration script, and create a password:

# emerge --config =dev-db/mysql-<VERSION>

Start the mysql database server:

# /etc/init.d/mysql start

In the file /etc/mysql/my.cnf , add the following lines to the [mysqld] section:


Now restart the MySQL server:

# /etc/init.d/mysql restart

Now login to MySQL and create a database and user for the wiki to use

Start the MySQL shell:

# mysql -u root -p mysql

Then create a Database and set the privileges:

# create database wikidb;
# grant create, select, insert, update, delete, alter, lock tables on wikidb.* to 'wikiuser'@'localhost' identified by 'password';
# flush privileges;
# set password for 'wikiuser'@'localhost'=password('yourpassword');
# \q

Installing Mediawiki

Fetching and Installing

Check your use flags. Use /etc/portage/package.use to enable math if you need formulas in your wiki. Emerge:

# emerge mediawiki -va

if you have enabled the vhosts use flag you need to tell portage where to install mediawiki: find the version of mediawiki you wish to install in here:

# ls /usr/share/webapps/mediawiki

then install via:

# webapp-config -I -d mediawiki mediawiki ${VERSION}

where -d ${dirname} is the directory under /var/www/localhost/htdocs/ in which you wish to install

Setting Edit Permissions

Give permissions to modify mediawiki/config, this is the default path.

This will give anyone permission to write to it

# chmod a+w /var/www/localhost/htdocs/mediawiki/config

You should change this to be more restrictive after you have configured your wiki

PHP Sessions

This setting will apply to all sites using PHP. Only use it if you understand the implications, or in fact want sessions at all. Seems to work ok without this anyway.

Find and change this value; in PHP 5.2.1-r3 this was on line 966:

File: /etc/php/apache2-php5/php.ini
session.save_path = "/var/www/localhost/"

Setting it up

Now start up Apache && MySQL:

# /etc/init.d/mysql start
# /etc/init.d/apache2 start

Launch your favourite browser, and go to Click on the link for setup.

Fill in the form. Do not give MediaWiki root access to your MySQL database, just set it up to use the wiki_editor user you set up earlier.

Press Install.

If everything went ok, you should see the following message: "Success! Move the config/LocalSettings.php file into the parent directory, then follow this link to your wiki."

Then, after you're done -- copy the configuration file into the base mediawiki directory:

# cd /var/www/localhost/htdocs/mediawiki/
# mv config/LocalSettings.php .
# chmod -R 700 config

And point your browser to

Congrats! Now you have your own wiki set up.

Where to Go From Here


Security is important. You'll regret not caring about it, when you lose all of your work.

Access restriction

There's a simple hack that adds |restrict| tab for pages. This will enforce a restriction for standard users, but not a group-based restriction. There instructions are for the stable version, 1.4.x. See reference.

# cd /var/www/localhost/htdocs/mediawiki
# wget
# patch -p0 < restriction-beta-0.54.mediawiki-1.4.9.patch
File: LocalSettings.php
// Enable the restriction feature.
// If set to false, all protected pages are accessible.
$wgEnableRestrict = true;

// sysop users can use restrict feature
$wgRestrictGroup = 'sysop';

// Hide restriction log entries for non-members users
$wgHideRestrictLog = true;

// Restrict user home page to the owner and to restrict members
$wgUserPageRestrict = true;

User Authorization

Customizing Your Wiki



For those impatient at heart, the default logo is skins/common/images/wiki.png. Under version 1.4 you can add items to the navigation block by manipulating the $wgNavigationLinks array which is defined in includes/DefaultSettings.php. Any changes should be made in LocalSettings.php, and if you are using a localized version, add the entry also to languages/<yourlocale>.php, under "bits of text used by many pages".


There is much more that you can do with the MediaWiki software. For a much more comprehensive guide, see:

Other Wikiservers In Portage

MediaWiki is not your only choice. Portage has a few more Wiki programs you can use.

www-apps/dokuwikiDokuWiki is a simple to use Wiki aimed at a small companies documentation needs.
www-apps/moinmoinMoinMoin is an advanced, easy to use and extensible wiki (Python)
www-apps/phpwikiPhpWiki is a WikiWikiWeb clone in PHP
www-apps/tikiwikiFull-featured Web Content Management System using PHP and Smarty Templates
www-apps/twikiA Web Based Collaboration Platform

Further Reading

For more information on Wikis in general, look at the following sites:


Installing MoinMoin

If you want an rss feed make sure to enable the rss use flag.

Emerge moinmoin:

# emerge -v moinmoin

Add the following section to /etc/apache2/httpd.conf (assuming you are using apache-2). This creates an alias so you can type <webserver_name>/wiki and get to the moinmoin wiki front page. It also allows the cgi file to run from the /var/www/localhost/htdocs/moinmoin directory.

File: /etc/apache2/httpd.conf
Alias /wiki "/var/www/localhost/htdocs/moinmoin"

ScriptAlias /mymoin "/var/www/localhost/htdocs/moinmoin/moin.cgi"

<Directory /var/www/localhost/htdocs/moinmoin>
        AllowOverride All

Restart apache:

# /etc/init.d/apache2 restart

Point your browser to and you should see a temporary front page for the moinmoin wiki. KeithGray 04:51, 5 November 2006 (UTC)

Upgrade Moinmoin from 1.5.8 to 1.6.1

The Gentoo Moinmoin package was update from 1.5.8 to 1.6.1 at 18/Feb/2007, this document will help you upgrade Moinmoin. please update you portage and emerge new version moinmoin.

Emerge new version of moinmoin

# emerge --sync
# emerge moinmoin

Duplicating Moinmoin instance for you

After emerged Moinmoin, Gentoo has created Moinmoin example instance:

I recommand you reserve these example instance to keep up their original state, and copy new instances for you.

# cd /var/www/localhost
# cp -fr moinmoin-1.6.1 moinmoin_mywiki-1.6.1
# cd htdocs
# cp -fr moinmoin mymoin

Migrating the pages

I assume your old Moinmoin instance that reside in /var/www/localhost/moinmoin_mywiki-1.5.8, now migrate the pages to new version moinmoin instance.

# cd /var/www/localhost
# rm -fr moinmoin_mywiki-1.6.1/data/pages
# cp -fr moinmoin_mywiki-1.5.8/data/pages moinmoin_mywiki-1.6.1/data

Edit the CGI script

Edit the /var/www/localhost/htdocs/moin.cgi with your favorite editor, change the parameter of function sys.path.insert(), let it point to directory where is in, /var/www/localhost/moinmoin_mywiki-1.6.1

File: /var/www/locahost/htdocs/mymoin
# Path of the directory where is located.
sys.path.insert(0, '/var/www/localhost/moinmoin_mywiki-1.6.1')

Configuring Moinmoin

Edit the Moinmoin configure file, /var/www/localhost/moinmoin_mywiki-1.6.1/wikiconfig, change the variable value following the file comment. below is key field:

File: /var/www/locahost/moinmoin_mywiki-1.6.1/
   # the key field of wiki configuration

   # this field in 1.5.8 version is named url_prefix
    url_prefix_static = '/mymoin'

    superuser = [u"RobinSwan", ]

    acl_rights_before = u"RobinSwan:read,write,delete,revert,admin"

Change the Moinmoin instance authorities for Apache

 # chown -R apache:apache /var/www/localhost/htdocs/mymoin
 # chown -R apache:apache /var/www/localhost/moinmoin_mywiki-1.6.1

Configuring Apache

Attach below section to the Apache config file /etc/apache/httpd.conf :

File: /etc/apache/httpd.conf
Alias /mymoin "/var/www/localhost/htdocs/mymoin"
ScriptAlias /mywiki "/var/www/localhost/htdocs/mymoin/moin.cgi"
<Directory /var/www/localhost/htdocs/mymoin>
        AllowOverride All

effect configuration

# /etc/init.d/apache2 restart

Now, you can use the moinmoin with you favorite browser, open url : http://localhost/mywiki

A regret

Moinmoin change some its wiki syntax in 1.6.x, I don't find any tool can change the wiki syntax of page autmactically, now I just modify the wiki syntax of my pages manually! Any one have best idea about the data migration from 1.5.8 to 1.6.x, please add it here, thanks in adavanced!

Of course there is a tool, please just read docs/README.migration (and docs/CHANGES).

Retrieved from ""

Last modified: Mon, 15 Sep 2008 12:42:00 +0000 Hits: 15,043