Search | Directories | Reference Tools
UW Home > UWIN > Computing and Networking > Web > Web Publishing > Installing Wikis 

Installing MediaWiki

MediaWiki is the wiki software developed for and by Wikipedia.

Included on this page:

Pre-Requisites

Using MySQL
MediaWiki requires MySQL, so if you don't already have it installed on your account, you'll have to install MySQL. You should also create an empty database for MediaWiki to use.
The link above explains how to install MySQL.

Note: We recommend disabling the InnoDB storage engine in MySQL before installing MediaWiki. If you use InnoDB, recovering from an unexpected system restart will be more difficult. You can disable InnoDB by including a line that says skip-innodb underneath the 'datadir' line in your .my.cnf file.

Installation

  1. Log in to your Homer or Dante account with Tera Term or another terminal emulator.

  2. Press the O key for Other, then press the W key to drop into the Web development environment (Ovid, Vergil or Socrates).

  3. Change directories to your public_html directory.

    cd public_html
  4. Download MediaWiki using wget.
    wget http://www.washington.edu/computing/web/publishing/mediawiki-1.12.0.tar.gz

  5. Unzip the file you just downloaded:

    tar -xzvf mediawiki-1.12.0.tar.gz
  6. Rename the directory to something easier to remember, or perhaps something that pertains to what you're going to use the wiki for.

    mv mediawiki-1.12.0 mediawiki
  7. Go to http://AccountType.washington.edu/UWNetID/mediawiki/config/ (where AccountType is the type of account you have and UWNetID is your own UWNetID) and fill out the config form.

    Most of the configuration form can be left with the defaults. You should set up at least the following:

    Site config
    Wiki name:The name of your wiki site
    Contact e-mail:Your email address
    Admin username:This will be your administrator login name for the wiki
    Password:The password for your wiki administrator account.
    Password confirm:The same thing.
    Database config
    Database host: webdev host.u.washington.edu:port#
    Database name:mediawiki (or whatever you named the database you created)
    DB username:Use a username you have created in MySQL with access to the MediaWiki database.
    DB password:The password for the MySQL user mentioned above.
    DB password confirm:The same thing.
    Database table prefix:(leave this empty)
    Storage Engine:MyISAM

    The "MySQL server" field is the most confusing one here. You'll need to enter the hostname of either ovid or vergil, depending on where your MySQL server is running. The port# will be the port number that you started MySQL on. This is located in your .my.cnf file if you don't remember.

    The Storage Engine field recommends InnoDB, but in our environment, MyISAM is more reliable. Please select this option for your Storage Engine.

    Press the "Install!" button to submit the form.

  8. The script now writes the database tables, inserts some data and creates the initial admin user, and writes the LocalSettings.php file into the config directory.

    You should move the LocalSettings.php file into the main MediaWiki directory. You can use the following command.

    mv mediawiki/config/LocalSettings.php mediawiki/LocalSettings.php
  9. Now MediaWiki will mostly work, but there are other configuration steps you should probably take in order to get good behavior from it.

    Here are some configuration variables that may or may not exist in the LocalSettings.php file. If they already exist, consider changing them as suggested. If they don't exist, consider adding them.

    $IP =rtrim(`wwwhome`)."/mediawiki";
    This is the path to your mediawiki directory. Unless MediaWiki has trouble with this you probably won't have to set it.
    $wgSitename =This should be whatever you want your site to be called.
    $wgLogo =This should be the path to your logo image.
    $wgEnableUploads ="true";
    This will enable file uploading.
    $wgFileExtensions =array( 'png', 'gif', 'jpg', 'jpeg' );
    This is the array of file extensions that can be uploaded. Add any file type you want to upload to this array. Don't add "php" or other executable script types unless you want to have your account disabled for security violations.

    Other configuration settings can be found on the MediaWiki Configuration Settings page.

Requiring UW NetID Authentication

The MediaWiki meta-wiki has a page about Authentication. Here I'll be detailing how to set up login via REMOTE_USER, which means that you can log into a MediaWiki installation via Pubcookie. This extension has been shown to introduce bugs that prevent uploding new versions of file attachments and force previewing before saving a page. I don't know what kind of other security flaws this extension might introduce, so use it at your own risk.

These instructions assume that you're in the mediawiki directory.

  1. The first thing you'll need to do is edit your LocalSettings.php file.

    Insert the following lines before the closing ?>:

    require_once('extensions/Auth_remoteuser.php');
    $wgAuth = new Auth_remoteuser();
  2. Next, download the Auth_remoteuser.php extension using wget.

    wget http://www.washington.edu/computing/web/publishing/Auth_remoteuser.php
  3. Move it to your extensions folder.

    mv Auth_remoteuser.php extensions/
  4. Add an .htaccess file. The one below should work, assuming you want to let anyone with a UWNetID use your wiki.

    AuthType UWNetID
    require valid-user
  5. Okay, it should work now. Send email to help@u.washington.edu if you have trouble.

Requiring UW NetID Authentication only for Editing

If you want anyone to be able to read your wiki, but you want editing the wiki to require users to log in with their UW NetID, then this configuration is what you need.

  1. In the mediawiki/extensions/Auth_remoteuser.php file, change the following lines:

    20) $wgGroupPermissions['*']['read'] = true;
    21) $wgGroupPermissions['*']['edit'] = true;

    These are lines 20 & 21 in my file. They used to say "false". Changing them to true will allow pages to be viewed without attempting authentication, and will display the edit button on pages, so that that prompt is available for users. We're not really going to let them edit pages without authenticating.

    I also found that a patch to line 119 was required to get rid of a warning.
    This is just cosmetic:

    119) if ( isset($_SERVER['REMOTE_USER']) && strlen($_SERVER['REMOTE_USER'])) { # added isset test for anonymous reading

    The part that is highlighted should be added to this line.

  2. Create a symbolic link to your index.php file called indexauth.php.

    ln -s index.php indexauth.php
  3. In your .htaccess file, put in the following lines:

    RewriteEngine on
    RewriteBase /YOUR_UWNETID/mediawiki
    
    RewriteCond %{QUERY_STRING} action=edit
    RewriteRule ^index\.php$ indexauth.php [R]
    
    RewriteCond %{QUERY_STRING} title=Special:Userlogin
    RewriteRule ^index\.php$ indexauth.php?title=Main_Page [R]
     
    <Files indexauth.php>
    AuthType UWNetID
    require user LIST OF ALLOWED USERS
    </Files>

    Make sure to substitute you own UW NetID for YOUR_UWNETID and the list of users you would like to be able to access your wiki for LIST OF ALLOWED USERS.

    There are two lines that may need adjustment for each installation of MediaWiki. The RewriteBase line and the require line. You can require valid-user if you want to open it to anybody, or a specific list or group or whatever.

    What this .htaccess file does:

    • Requests for editing pages redirect to the symlink of your index.php file.
    • Requests for the user login page redirect to the main page via the indexauth.php symlink.
    • The indexauth.php symlink is protected by UW NetID authentication, so any request for that file will send the user to log in unless they're already logged in. If they are logged in with a UW NetID, they just get authenticated in MediaWiki.


  4. Other Useful MediaWiki Documentation