Manual:Moving a wiki
This page explains how to move a wiki to another server. This is often needed when moving to a different web server or domain (or both).
(Note: if you are looking to just move your wiki e.g. from /var/www/html/ to /var/www/html/mywiki/ instructions are here).
- 1 Versions and upgrading
- 2 Overview
- 3 Frequent problems
- 4 See also
- 5 External links
- 6 Notes
Versions and upgrading
The instructions on this page should apply more or less evenly to any given version of MediaWiki. Ensure, prior to moving, that any upgrading of the software and database schema is done. You should only move a database into another MediaWiki installation if they both run the same version. If you need to do both, make sure to upgrade before migrating to a different web server.
Choose a method for transferring files:
- SCP or WinSCP
- SSH File Transfer Protocol (SFTP)
- Using an FTP client.
- Using rsync
- The hosting company might provide a file manager interface via the web browser, check with your provider.
- Some other method, there is a list of these at Wikipedia:List of file transfer protocols
- Back up the database
- Back up the MediaWiki files
- Re-create the database, user and permissions
- Import the database backup
- Import the MediaWiki files
- Check the configuration file
Back up the database
|TIP: Wiki in read only mode|
Before you start the backup your wiki, you may want to put it under "read-only" mode so that nobody can edit it while you are moving it. If you don't, you might lose edits/uploads/logs etc. that were made during the migration process. To do this, use
$wgReadOnly = 'Down for maintenance, access will be restored shortly';
To move or copy your wiki, you need to start by making a backup of everything. You should probably copy at least the following:
- The wiki's database content. See Manual:Backing up a wiki.
- Images and other media files, i.e., the contents of the images and if modified any files from the skins directory.
- Favicon and .htaccess files.
- Configuration files, e.g., LocalSettings.php and (on older wiki's maybe AdminSettings.php as well).
- The contents of the extensions folder.
Extract uploaded files (images)
Requires shell access to the server:
- Go to the maintenance directory
- Create a subdirectory backup
- Use DumpUploads.php to extract the location of the uploaded images
php dumpUploads.php > listOfMediafiles.txt
- The content in listOfMediafiles.txt looks like
mwstore://local-backend/local-public/7/7a/STAT-Folnode6_c_3.gif mwstore://local-backend/local-public/9/90/STAT-Folnode6_c_4.gif mwstore://local-backend/local-public/d/d9/STAT-Folnode6_c_5.gif ...
- Replace in a editor mwstore://local-backend/local-public/ with the (absolute) path to the /my/wiki/images/ to have a file list
xargs -a listOfMediafiles.txt cp -t /my/wiki/maintenance/backup
- Now your uploaded files/images are in the backup directory and can be copied and reimported with importImages.php
Set up the destination database
On the destination server, create a new MySQL database and a user, and grant that user permissions on the database. SELECT, INSERT, UPDATE and DELETE permissions should suffice. You also need DROP, CREATE and ALTER to import the data base. You may need to consult the MySQL documentation, your hosting provider's control panel documentation, or the documentation of any other utilities you are using for information on how to do this.
Note: The destination database may have a different name, user and/or password. If that is the case, you only have to update the configuration file on the new server (after you completed the following steps, though).
Import the database backup
The next step is to import the database backup. This creates the tables in the database and populate them with data. Duplicating the database on the other server. Importing takes a variable amount of time, depending upon the number of pages, users, edits, etc. in the wiki.
See Manual:Restoring a wiki from backup for the full details. Possible methods for performing the import include:
- From the command line using mysql
- With phpMyAdmin via a web browser (not recommended for large databases due to potential timeout problems that could leave the database only partially imported, and perhaps in an inconsistent state, e.g., with revision metadata imported but not the corresponding revision text)
- From an XML dump
- Using BigDump if you don't have command-line access and your MySQL administration tool has an upload size limit that is lower than the size of your database.
Import the MediaWiki files
The final "large" step in the moving process is to upload/copy the MediaWiki files (the "wiki" folder) to the destination server. If you followed the instructions above, and backed up the entire directory, this includes the images and extensions directories, plus custom skins, etc. and the configuration file.
If you backed up only portions of the directory, e.g. images, extensions, etc. then you must first upload or copy a fresh install of the MediaWiki files, then transfer the backed-up directories and files into the correct locations in the new filesystem.
- If following the latter process, ensure that your "fresh install" consists of the same version of MediaWiki as the old one did
- Check that the upload/ directory (called images/ in MediaWiki 13 and below) has the correct permissions set if using uploads; it must be writable by the web server.
- Make sure any extension directories have the correct permissions as well (e.g., if linux:
chmod -R o=rx extensionsor
chmod -R o=rx includes)
- When manually transferring a wiki from a windows platform to a Linux platform the best method is to:
- Manually installing wikimedia on the Linux platform from a tar file as outlined here: Manual Install of Wiki (i.e., try not to use install from a automated package)
- Replacing the newly installed wikimedia folder (e.g., /var/www/mediawiki...) on your Linux machine with the wikimedia base folder from your windows machine
- Updating your Linux machine's MySQL Database (e.g. wikidb) with the wiki database from your windows machine (i.e., use the backup and restore features of mysql as outlined above)
- After importing a wiki database, even if the database can work, some minor problems may arise:
- You might need to repair Searchindex: In phpMyAdmin, enter "REPAIR TABLE wikidb.searchindex; " for rebuilding the search index. wikidb is your database's name.
- The collation of some rows may be changed. Cross check it with the original database.
Update the configuration file
The final step is to update the LocalSettings.php file. Certain entries in this will almost undoubtedly require changing.
Check the following configuration options:
|$IP||Usually this is set automatically. However if you set it manually, it must be updated to absolute local file path to the MediaWiki directory on the new server.||Default:
$IP = dirname( __FILE__ );
||Needs to match the hostname of where the new wiki is served from
(must not have a path, that's for
$wgServer = 'http://example.org';
||Needs to match the public url to where the MediaWiki directory is on the new server||Example:
$wgScriptPath = '/w';
||Needs to match where wiki pages are now primarily read from. See also Manual:Short URL if you have short urls set up to make sure that still works.||Examples:
$wgArticlePath = '/w/index.php?title=$1'; $wgArticlePath = '/wiki/$1';
||The hostname to the new database server.||Example:
$wgDBserver = 'localhost';
||The name of the database. Be sure that this includes any prefixes that your (new) hosting provider may have enforced.||Example:
$wgDBname = 'igot_mwiki';
||The username that MediaWiki should use to login on the database server.||Example:
$wgDBuser = 'igot_mwiki';
||The password for the (new?) wgDBuser.||Example:
$wgDBpassword = 'xxxxxxx';
At this point, try to use the wiki on the new server. Log in as a sysop and a regular user and check that viewing, creating and editing pages and uploading files still works. Fix any problems reported either by PHP or MediaWiki itself.
- Inaccessible files after the changing the domain
The column md_deps in the module_deps table contains absolute file paths, which are used to locate the images and LESS files that CSS depends on. These paths break when the wiki is, e.g., moved to another folder or another server. After your move, you might see PHP warnings that certain files could not be accessed. In current versions of MediaWiki, this can be solved by running update.php, thus clearing caches.
In versions older than MediaWiki 1.25 (where phabricator:T37472 is not implemented), update.php does not delete the contents of the module_deps table. For these versions, the workaround is to manually fix wrong entries in the module_deps table:
-- Update entries in module_deps table SET @old='wiki.old-domain.org'; SET @new='wiki.new-domain.org'; UPDATE `module_deps` SET `md_deps` = REPLACE( `md_deps`, @old, @new );
This can be used to update wrong path segments and to fix the error.
A similar issue can happen when MediaWiki tries to read resource loader messages. In this case the solution is to truncate the according tables:
-- Truncate message related caches TRUNCATE TABLE `msg_resource`; TRUNCATE TABLE `msg_resource_links`;
- Manual:Restoring a wiki from backup
- Manual:Backing up a wiki
- Manual:Installing MediaWiki
- Manual:Restoring wiki code from cached HTML (if you don't have a successful backup)
- Manual:Short URL#Moving a wiki from /wiki to /w (change the installation directory of your wiki)
|Language:||English • 日本語|