Migrating MediaWiki from Hosted Apps

Dave Brondsema Wayne Davison Thomas Friedrichsmeier Nicola Soranzo Rich Bowen Jeffrey Wang

Migrating MediaWiki from Hosted Apps to Project Web

Note: The Hosted Apps platform has been retired on 2014-06-19


Before moving MediaWiki...

Post to your wiki's MediaWiki:Sitenotice that you will be moving your wiki, and that further edits will not be saved.

1) Get backup of your MediaWiki data

You will find a backup of your MediaWiki data in your project's (or user's) web directory root. For a project named PROJECT these are:

/home/project-web/PROJECT/p_PROJECT_mediawiki.sql.gz (the database dump)
/home/project-web/PROJECT/p_PROJECT_mediawiki.tar.gz (the web files)

For a user you will have /home/user-web/USER/u_USER_* files instead. You can copy these using rsync/scp/sftp from web.sourceforge.net using your sourceforge username and password.

2) Enable MySQL for your project

In classic:
Project Admin -> Features and click on ‘Manage’ next to the MySQL option

In Allura:
Admin -> Tools -> Mysql

Make sure that you’ve set passwords for your various access accounts, and make note of your required database hostname and prefix for the following step.

3) Load the database dump into your project database

log into your account via ssh:

ssh -t USER,PROJECT@shell.sourceforge.net create

Create a new database for your MediaWiki installation, using the database hostname and prefix noted in step 2 above.

mysqladmin -h mysql-r -u r12345admin -p create r12345_mediawiki

Load the database dump:

zcat /home/project-web/PROJECT/p_PROJECT_mediawiki.sql.gz | mysql -h mysql-r -u r12345admin -p r12345_mediawiki

4) Install MediaWiki in your project web space

Obtain the latest version of MediaWiki at http://www.mediawiki.org/wiki/Download

cd /home/project-web/PROJECT_NAME/htdocs
wget http://releases.wikimedia.org/mediawiki/1.22/mediawiki-1.22.6.tar.gz
tar -vzxf mediawiki-1.22.6.tar.gz
mv mediawiki-1.22.6 wiki
rm mediawiki-1.22.6.tar.gz

Point your browser at http://PROJECT.sourceforge.net/wiki (or whatever you set your path to) to start the web installer.

Click through the screens until you get to the database screen. Select Mysql as your database type, and fill in the database information from step 3 above, using the Admin user account.

Click Continue. You will see a screen that says:

There are MediaWiki tables in this database.
To upgrade them to MediaWiki 1.22.6, click Continue.

Click Continue.

5) Regenerate LocalSettings.php

On the next screen click the "Regenerate LocalSettings.php" button. Fill in the desired information on the screen to set up your new wiki settings. After filling out these screens, you will be prompted to download your LocalSettings.php file.

Edit the LocalSettings.php file to use the RW database account above instead of the Admin account.

Then upload it to your wiki directory.

scp LocalSettings.php USERNAME@web.sourceforge.net:/home/project-web/PROJECTNAME/htdocs/wiki

Using an SFTP client or the Shell Service, change the permissions on your LocalSettings.php file so the credentials are properly protected.

chmod o-r /home/project-web/PROJECTNAME/htdocs/wiki/LocalSettings.php

6) Import image (and other) files into your Mediawiki install

In the project web shell, unpack the files to the images directory of you wiki installation. In the backup, the images are in a subfolder projectname, so follow these steps:

cd /home/project-web/PROJECTNAME/htdocs/wiki/images
tar -xvzf /home/project-web/PROJECT/p_PROJECT_mediawiki.tar.gz
# Now fix permissions in the current directory (".") which is the images dir.
# Wrong permissions may cause a massive slowdown!
chmod ugo+rX --recursive .

It may take a few pageloads for MediaWiki to regenerate any thumbnails that weren't in the backup. This is normal.

7) Configuration changes

Edit LocalSettings.php and make the following changes:

To be able to send outbound email (eg, for password resets) set your outbound email authentication password as described at https://sourceforge.net/p/forge/documentation/Project%20Web%20Email/ . Then add the following to the bottom of LocalSettings.php:

# Authenticated mail settings
$wgSMTP = array(
'host'     => 'prwebmail',
'IDHost'   => 'PROJECTNAME.sourceforge.net',
'port'     => 25,
'auth'     => true,
'username' => 'PROJECTNAME',
'password' => 'PASSWORD'

The logo shown in the sidebar is no longer stored as an object in the wiki (as it was in the Hosted App installation). Rather save it as a regular file, then change the value of $wgLogo:

$wgLogo = "$wgScriptPath/images/path/to/logo.png";

Set write permissions as restrictively as you can:

$wgGroupPermissions['*']['edit'] = false;
$wgGroupPermissions['user']['edit'] = false;
$wgGroupPermissions['admin']['edit'] = true;

Or possibly set 'user' to true, depending on how you want things done.

This will make it less likely that the general public can deface your wiki with spam.

Some notes on performance

Performance is pretty slow, esp. after touching LocalSettings.php. Don't panic! Things do get considerably faster after about one or two days. There are some things you can do to help performance, though:

All project web pages currently go through an http cache (varnish). It still seems to help some, to enable MediaWikis file cache in addition to that. Try these settings in LocalSettings.php:

$wgUseFileCache = true;
$wgFileCacheDirectory = "{$IP}/cache";
$wgShowIPinHeader = false;        # Meaningless anyway due to varnish http cache
$wgUseGzip = true;
$wgEnableSidebarCache = true;

$wgDisableCounters = true;        # No major effect, but counters are useless
                                  # due to caching, anyway
$wgMiserMode = true;

8) Test MediaWiki

Try reading an article, editing an article, reassigning user rights, uploading an image, creating and deleting a page, and also putting an image on an article. If all works fine, you can use MediaWiki again. If not, from the command line, in the maintenance directory, type in

$ php update.php --quick --force

This will reapply object permissions and may resolve rights problems.

9) User permissions

To restore user permissions, tell your users to send themselves a password reset using the email address USERNAME@users.sourceforge.net

Known issues

Uploads of images and other files do not work due to a problem with locking files. See ticket #2583 . One workaround given in a comment to that this is as follows:

In the mediawiki source code I changed line 97 in includes/filebackend/FileBackendGroup.php from

              'lockManager'    => 'fsLockManager',


                'lockManager'    => 'nullLockManager',

Help and Support

If you need any help with your wiki, please ask below and an expert will come to help you as soon as possible.


Community Docs: Hosted Apps Retirement
Community Docs: Migrating WP from Hosted Apps
Site Support: #10065
Site Support: #7772


1 2 3 > >> (Page 1 of 3)
  • Jeffrey Wang
    Jeffrey Wang

    Hello Robert,
    You said that you had issues when viewing the "blog". What does that mean? Also, please tell me your project and I can help you. Remember, you need to export the databases, then reimport them somewhere on Project Web, then point MediaWiki's LocalSettings.php to that location.

    I believe your MediaWiki version that you got was something like MediaWiki 1.13? I'm not sure, I'll go check.

    UPDATE: It's MediaWiki 1.15 that SourceForge uses.

    Last edit: Jeffrey Wang 2012-07-11
  • Jeffrey Wang
    Jeffrey Wang

    No. Download MediaWiki 1.19. The guide mentions to download only MediaWiki 1.19.

    Last edit: Jeffrey Wang 2012-07-14
  • Lewis Cawte
    Lewis Cawte

    If the guide told you to go through the web installer, I believe it'd flag up this problem and halt install, which has been a problem for a while, and I opened a ticket when 1.19 was still in a very early alpha. Here is a link to the ticket.

  • Roland Kuebert
    Roland Kuebert

    @Jeffrey: It's Roland, not Robert. :)

    I've got the same error as Matt and the others (text is shown when editing but not in normal mode). Somehow I got it half working at one point in time, then only the images did not work, but I don't remember what I did. :/

  • bnash31

    Same experience as Roland. It worked briefly after running php update.php twice. Also, the images wouldn't show up. I tried to figure out where to put the image files and hopefully put them in the right place. Later, the main text wouldn't show up any more.

  • Ahmed Eldeep
    Ahmed Eldeep

    why we still get no answear here??

    • Rich Bowen
      Rich Bowen

      This document is awaiting two very specific changes, which are scheduled and have engineers assigned to them. That's why the document is marked as still in progress, and not a completed document. Meanwhile, some edits have been made that are generally good MediaWiki advice but don't apply specifically to the SourceForge environment.

      Once the ticket in question (https://sourceforge.net/apps/trac/sourceforge/ticket/21313) is resolved, this document will be completed. Until that ticket is resolved, this document is incomplete and will remain so.

      I'll try to make this clearer in the document itself.

  • Hi there,

    I experience same problems that everybody with version 1.19.

    I managed to upgrade from version 1.13 which it was the hosted app version to a 1.17.5 with good results. The only issue is that there is not openid authentication so no way to use your actual sf user to manage this wiki. Only local users, but since I can't configure mediawiki to send the mails, is not possible to create users.

    I find this transition a bit chaotic and with contraction information. If transition is not possible yet, remove this article that only can confuse developers.


    Last edit: Victor Barahona 2012-07-23
    • Lewis Cawte
      Lewis Cawte

      I believe this page may be useful, iirc this was the way to configure email when I last tried it, but I haven't installed MediaWiki on SF since 1.17 was in beta.

      If anyone needs help migrating, let me know - I've installed my fair share of MediaWiki on and off SourceForge

      • Lewis Cawte
        Lewis Cawte

        To expand on that, use this configuration variable in LocalSettings.php with the details in my last reply.

  • Rich Bowen
    Rich Bowen

    I was under the impression that those versions were no longer available for download, due to security reasons.

    • Lewis Cawte
      Lewis Cawte

      MediaWiki is open source, and uses version control systems, until recently it used SVN (now it uses Git), also the Wikimedia Foundation (who host the MediaWiki development) has all of the releases on its website, from version 1.3 as can be seen here - generally 1.X has new features, 1.x.y has security fixes. Yes its generally a good idea to stay at the latest release however 1.16 isn't that old in terms of MediaWiki, and the biggest MediaWiki host Wikia has only just decided it worthy to upgrade, but there are stable and secure sites out there that are using versions of MediaWiki from 5 or more years ago...

      • Rich Bowen
        Rich Bowen

        If people want to take the responsibility for installing back versions of software that is of course their call. I'm not at all keen to recommend it in official docs because we have an open ticket.

  • Dear Sirs,
    how can I migrate from MediaWiki (hosted apps) to the new integrated Wiki available with Allura platform?
    I googled a few, but I was not able to find out useful information; copy & paste from MediaWiki to Wiki does not work :(
    Thanks in advance

  • Gert Wollny
    Gert Wollny

    I'd like to add my voice in support of the question posed by Christian Ferrari. I'm aware that there is some kind of support for this transitition, (Allura Tickets #4186 and #4660 ) but a tutorial on how to apply this would be nice.

    Many thanks.

  • I just migrated a wiki from hosted apps to the project web (mediawiki 1.20) using the method above, and everything works fine, except:
    - The method to "beautify" urls seems to make the wiki unable to load its skins, I had to undo it
    - the php command to remove unused SF-created wiki users didn't work
    - The OpenID plugin doesn't seem to work, although all needed php dependencies seem to be there

  • Step 3 is really underspecified. Can you give examples about what the following are, so I can better tailor to my own project:

    mysqladmin -h mysql-r -u r12345admin -p create r12345_mediawiki

    what is:
    * mysql-r
    * r12345admin
    * r12345_mediawiki

    When I set up Mysql in step 2, I chose the default', which gave me MySQL as a label and sfx-mysql as a mount point.

    • Rich Bowen
      Rich Bowen

      The terms are defined in step 2. They are the database prefix and usernames.

  • Oliver Eichler
    Oliver Eichler

    I get that error message in my browser, when I try to setup the wiki as described in step 4.

    Error starting session: session_start() [<a href='function.session-start'>function.session-start</a>]: open(/tmp/persistent/qlandkartegt/sess_38bpp815m2edqsroh1jj3fjng5, O_RDWR) failed: No such file or directory (2)

    Any idea how to get access to that path?

  • Favux

    The initial user/administrator is not always created by the MediaWiki installer and there is a simple work around using createAndPromote.php. Maybe one of the causes is using the same sysop/administrator/first user name as in the migrated database? Since that "user" is already there it won't create the account. Log into the shell and go to the wiki/maintenance directory. Run:
    php createAndPromote.php --sysop --bureaucrat <your new sysop name> <new password>
    Then at least you can do the local login as administrator.

    Step 8 (9) is too terse, expanding it a bit would be nice. Check your LocalSettings.php. In the shell go to /wiki and use nano:
    nano LocalSettings.php
    You should see:
    $wgEmergencyContact = "apache@<project name>.sourceforge.net";
    $wgPasswordSender = "apache@<project name>.sourceforge.net";

    1. Go to the migrated wiki's url.
    2. Go to 'Log in', top right corner of the page.
    3. On the 'Log in' page click on "Forgotten your login details?"
    4. On the 'Reset password' page enter your SourceForge user name and click on the "E-mail new password" button.

    You should get an e-mail with the temporary password. Log in again. When you enter the temporary password a "Change password" page pops up. Enter a throw away password you don't use anywhere else and click on the "Set password and log in" button. Need to wait for OpenID implementation before they'll provide a SourceForge login I guess.

    My question.
    The migrated MediaWiki is often sluggish compared to the hosted MediaWiki. Is there performance tuning we can add to LocalSettings.php to help?

    A link to a bare bones LocalSettings.php example that works on SourceForge would be helpful.

    Last edit: Favux 2012-12-20
  • Oliver Eichler
    Oliver Eichler

    I am still stuck at step 4. If I go to the wiki page:


    and click on the link to setup the wiki, I just get an error message.

    • Rich Bowen
      Rich Bowen

      I get the message "LocalSettings.php not found. Please set up the wiki first." You need to click the link and proceed with the installation.

1 2 3 > >> (Page 1 of 3)