Creating New Wikis

From ResonantMetaWiki
Jump to: navigation, search


This is a basic guide to installing multiple MediaWiki 1.7 wikis side by side on a Debian GNU/Linux system running Apache 2. It's for local reference at and may or may not be particularly useful to other readers.

Relevant configuration files and locations


This is where the main Apache2 configuration for the wikis will go.


This is where the individual wiki directories will go. This directory should not already be in use by the webserver (i.e. it's for a system that places individual hosts in directories like /var/www/ and doesn't use /var/www/ directly -- if you do use /var/www/ directly, you need to pick another spot for this).

The naming convention is to pick the word that will be the URL path name to the wiki being created and prefix it with an underscore. For example, this wiki is accessed as, so it lives in /var/www/wikis/_mw.


This is the actual final location of the settings for wiki foo. It will actually have to be moved out of the config subdirectory and slightly edited as a final step before the wiki can be used.

Setting up a new MediaWiki

System configuration

The first thing you will need to decide on is a name. For the sake of example, we'll pick the name foo. The first step is to create the directory for it:

 mkdir /var/www/wikis/_foo

Once you have decided on a name and created its directory, you will need to symlink most of the files in the /usr/share/mediawiki1.7 directory into it, but recreate a few directories locally:

 cd /var/www/wikis/_foo
 ln -s /usr/share/mediawiki1.7/* .
 rm -f config ; mkdir config ; chown www-data.www-data config
 rm LocalSettings.php

If you want to share a global file upload area between wikis, then you can stop here. Otherwise, you also need to:

 rm -f upload ; mkdir upload ; chown www-data.www-data upload


 cp -a /var/lib/mediawiki1.5 /etc/mediawiki/wikis/_foo
 chown -R www-data.www-data /etc/mediawiki/wikis/_foo

Now edit /etc/apache2/sites-available/wikis. All of the wikis will be under their own subdomain, so a virtual host is required. The top of the file will look like:

<VirtualHost *:80>
  SSLEngine off
  DocumentRoot /var/www/wikis
  php_flag register_globals off

And now mod_rewrite rules to make the wiki accessible. The first line after the RewriteEngine command is to redirect the root page to whichever wiki you want to show up by default. In our case, it's this metawiki.

  RewriteEngine on
  RewriteRule ^/$ /mw/Main_Page [R] 

And then RewriteRules for each wiki location -- add in the new name in the following format:

  RewriteRule ^/foo/?(.*)$ /_foo/index.php?title=$1 [L,QSA]
  RewriteRule ^/anotherwiki/?(.*)$ /_anotherwiki/index.php?title=$1 [L,QSA]

That ends the VirtualHost part, but we're not done with the file yet. Now we need to set some permissions, first on the main MediaWiki directories:

<Directory /var/lib/mediawiki1.7/>
  Options +FollowSymLinks
  AllowOverride All
  order allow,deny
  allow from all
<Directory /var/lib/mediawiki1.7/config>
  Options -FollowSymLinks
  AllowOverride None
<Directory /var/lib/mediawiki1.7/upload>
  Options -FollowSymLinks
  AllowOverride None

... and then also on the wiki-specific directories:

<Directory /var/www/wikis/_foo/>
  Options +FollowSymLinks
  AllowOverride All
  order allow,deny
  allow from all
<Directory /var/www/wikis/_foo/config>
  Options -FollowSymLinks
  AllowOverride None
<Directory /var/www/wikis/_foo/upload>
  Options -FollowSymLinks
  AllowOverride None

<Directory /var/www/wikis/_anotherwiki/>
  Options +FollowSymLinks
  AllowOverride All
  order allow,deny
  allow from all
<Directory /var/www/wikis/_anotherwiki/config>
  Options -FollowSymLinks
  AllowOverride None
<Directory /var/www/wikis/_anotherwiki/upload>
  Options -FollowSymLinks
  AllowOverride None

Once you have done this, you will need to restart Apache:

/etc/init.d/apache2 restart

Now, if you have done everything right, you will be able to go to the configuration screen for your new wiki, using the name with the underscore, something like to get the MediaWiki configuration screen. If you fail to use the underscore, you will get a blank page with a prompt with a hyperlink stating "You'll have to set the wiki up first!". If you attempt to click on that link, it will probably break. Just go back and put the underscore back in.

MediaWiki initialization

Copyright/License Metadata

This is several options down, but there's a reason that I'm placing it at the top. If you choose a Creative Commons license here, you need to do so as your first step, as going through the selection screen will wipe out any other information you have entered on the configuration page.

As a general rule, if you are creating a private wiki, don't enter any license information at all (copyright law defaults to all rights reserved, which is probably what you want). If you are creating an open wiki, what you probably want is non-commercial, anyone can modify if they share alike. Further information on Creative Commons licensing can be found at the Creative Commons FAQ.

Site Name

Enter the WikiName of the site. This should be ideally an easily recognizable word with no spaces or special characters, using StudlyCaps to create a compound word. Don't use punctuation.

Sysop account name/password

Set the sysop account name to be whatever you're comfortable with. It's wiki-specific, unlike the database account below.

Shared memory caching

Select Memcached. Set the Memcached server to be localhost:11211

Database Config

Set the database name to be the file storage directory prepended with wiki, e.g. wiki_foo. Leave the wiki username to be wikiuser unless you want to use a different username for every wiki, which could eventually become a bit cumbersome. REMEMBER THE PASSWORD! -- if you use the username wikiuser and a password other than the standard password, it will change the password to the new value and break every existing wiki until it is corrected or the configuration files for all wikis using the wikiuser account are updated.

Don't set a database table prefix, and enter the MySQL root account password at the bottom so the script will have permissions to do its work. In theory, MediaWiki now supports PostgreSQL. I had no luck with either 7.4 or 8.1, so it seems best just to stick with MySQL, even if it means running two databases side by side.

Click Install, and the script will generate a configuration file for you in /var/www/wikis/_foo/config/LocalSettings.php. Copy this file into the parent directory and fix its permissions and ownership (it has a password in plaintext)

cd /var/www/wikis/_foo
cp config/LocalSettings.php .
chown www-data.www-data LocalSettings.php
chmod 600 LocalSettings.php

Now edit this file. It's almost done.

LocalSettings.php configuration

Set $wgScript to /foo/index.php
Set $wgRedirectScript to /foo/redirect.php
Set $wgArticlePath to /foo/$1
Set $wgLogo to whatever you want to use for you logo. The logo is — unfortunately, it doesn't really work perfectly on a white background, so some retheming may eventually be in order.

Privacy Settings

If you need to restrict access, you can disable new account registration except by Sysops, make an account required to edit (highly recommended to cut down on anonymous spamming), or make an account login required to view all but a selected list of public pages. For full details see MetaWikiPedia:Preventing_Access.

To enable the settings, below the first batch of =$wg= settings, you can paste in any or all of the following blocks, commenting out whichever ones you don't want to be true by prepending '#':

# Prevent new registrations from anonymous users
# (Sysops can still create user accounts)
$wgGroupPermissions['*']['createaccount'] = false;

# Prevent editing from anonymous users
$wgGroupPermissions['*']['edit'] = false;

# Pages anonymous (not-logged-in) users may see
$wgWhitelistRead = array( "Main Page", "Special:Userlogin", "-", "MediaWiki:Monobook.css", "Wikipedia:Help" );
#german:$wgWhitelistRead = array( "Hauptseite", "Spezial:Userlogin", "-", "MediaWiki:Monobook.css" );
$wgGroupPermissions['*']['read'] = false;

Special Features

If you want to enable uploads (for images or other files that should be stored as part of the wiki), set:

$wgEnableUploads              = true;

by removing the '# ' in front of the variable.

If you want to allow inline images that are external to the wiki, add the line:

$wgAllowExternalImages        = true;

If you want to enable LaTeX support for math symbols (using <math> and </math> as limiters), uncomment:

# $wgUseTeX                   = true;

again by removing '# ' from the front.

Save the file. At this point, the wiki should be functional. You can check on this by visiting it at http://www.math.lsu/edu/wikis/foo (without the underscore).

Interwiki configuration (optional)

This stage isn't absolutely necessary, but will allow you to seamlessly use the WikiPedia and MetaWikiPedia help pages as if they were local to your own Wiki. From the shell, type:

mysql -u root -p and type in the MySQL root password.

At the MySQL prompt, type use wiki_foo to select the database, then paste the following:

REPLACE INTO interwiki (iw_prefix,iw_url,iw_local) VALUES

This has just generated the standard WikiPedia and MetaWikiPedia Interwiki entries, so you can cut and paste from those sites, or redirect to them transparently. (Note: I had some problem with the meta: prefix even after this, though m: worked just fine.)

!!Final configuration

Log into the wiki as the Sysop account by using the Log In link at the upper right of the page. Usernames are not case sensitive (and in fact, the first letter will always end up capitalized after you log in). Now is a good time for you to create your own account and give yourself full permissions. Click on Special Pages at the lower left, then click on the first link, Create an account or log in. If you are creating an account for yourself, type in your username, your password, e-mail and real name, then click the Create new account button. If you are creating an account for someone else, fill in all of the data except the password, then click by e-mail. A random password will be generated and mailed to the e-mail address specified as the account is created.

If you created the account for yourself, you will have suddenly had the disadvantage of being logged into that account... without your Sysop privileges. Log out, and log back in as the Sysop account. Go back to the Special Pages link, then scroll all the way to the bottom to select User rights management. Type in your username, and select Sysop and Bureaucrat permissions (this allows the account to not only administer the wiki, but create other sysop accounts), and click the Save Usergroups button. Note that while the login screen is not case sensitive, this page IS case sensitive. Make sure the first letter is capitalized. Log out and back in as your own, freshly Sysoped account and create any other user accounts and promote them as needed.

Now it is time to set up redirects in the help pages, which start out blank. Click *Help* on the left sidebar, which will bring you to the *Help:Contents* page. Edit this page, and add the following line:

#Redirect [[m:Help:Contents]]

Before you save the page, middle-click Editing Help down at the bottom to bring it up in a new window. You will want to edit it next. Then save the page.

Go to the Help:Editing window you just brought up and edit that entry as well, adding the line:

#Redirect [[m:Help:Editing]]

If you didn't use the Interwiki entries as suggested above, you will have to use [[MetaWikiPedia:Help:Contents]] and [[MetaWikiPedia:Help:Editing]] respectively, and instead of being directly sent to the [MetaWikiPedia help pages|MetaWikiPedia:Help:Contents], you will be shown a redirect page with one more link you will have to click on to go there.

Once this is done, the Wiki is ready for use. If you are also running a MetaWiki, you may want to add a link there to your new wiki.