Manual:Moving a wiki
This document is about how to move a wiki to another server. This is often needed when moving to a different web server or domain (or both).
Contents |
[edit] 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 upgrade before migrating to a different web server.
[edit] Overview
- 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
- Test
[edit] Backup
- See also Manual:Backing up a wiki.
To move or copy your wiki, you need to start by making a copy (i.e. a backup) of everything. You should copy at least the following:
- the wiki's content, from the database.[1]
- images and other media files
(the contents of the images directory) - configuration files;
LocalSettings.php and (if present) AdminSettings.php as well. - MediaWiki core files
- Extensions
(the contents of the extensions directory)
Note: Before you start the backup your wiki, you may want to set the origin wiki in "read-only" mode so that nobody can edit the old wiki while you are moving the wiki. If you don't you may lose edits/uploads/logs etc. that were made during the migration process. To do this, use $wgReadOnly.
[edit] 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 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 will only have to update the configuration file on the new server (after you completed the following steps, though).
[edit] Import the database backup
The next step is to import the database backup you made earlier. This will create the tables in the database and populate them with data. Following this point, you will have a duplicate of the database on the other server. Again, according to the means you are using to manage your MySQL databases, the process for this varies. You may need to upload the .sql script file from earlier to your server via FTP, or this may be done for you by the utilities you are using. Consult the documentation to find out how it's done.
After importing, which takes a variable amount of time, depending upon the number of pages, users, edits, etc. in your wiki, you should have a few dozen tables in the new database.
[edit] Possible methods
Possible methods for performing the import include:
- mysqldump
- phpMyAdmin or a similar tool
- The command-line console, mysql
- MySQL Administrator tool
- BigDump (this one is recommended if you don't have command-line access and your MySQL administration tool has an upload size limit that is higher than the size of your database)
[edit] 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 will include 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 will need to first upload/copy a fresh install of the MediaWiki files, then transfer the backed-up directories and files into the correct locations in the new filesystem.
[edit] Notes
- 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 (e.g. images in version 13) has the correct permissions set if using uploads; it needs to 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 extensions or chmod -R o=rx includes)
- The best method to use when manually transferring a wiki from a windows platform to a Linux platform involves:
- 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:
- Searchindex may need to be repaired: 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.
[edit] 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:
Configuration option | Description | Default/Example |
---|---|---|
$IP | Usually this is set automatically. However if you set it manually, it needs to be updated to absolute local file path to the MediaWiki directory on the new server. | Default:
$IP = dirname( __FILE__ ); |
$wgScriptPath | Needs to be correct for the path on the new server | Example:
$wgScriptPath = '/w'; |
$wgArticlePath | Needs to be correct for the path on the new server | Examples:
$wgArticlePath = '/w/index.php?title=$1'; $wgArticlePath = "$wgScript/$1"; $wgArticlePath = 'wiki/$1'; |
$wgDBserver | The hostname to the new database server. | Example:
$wgDBserver = 'localhost'; |
$wgDBname | The name of the database. Be sure that this includes any prefixes that your (new) hosting provider may have enforced. | Example:
$wgDBname = 'igot_mwiki'; |
$wgDBuser | The username that MediaWiki should use to login on the database server. | Example:
$wgDBuser = 'igot_mwiki'; |
$wgDBpassword | The password for the (new?) wgDBuser. | Example:
$wgDBpassword = 'xxxxxxx'; |
You might also need to check the paths to diff3, ImageMagick, etc.
[edit] Test
At this point, attempt to access the wiki on the new server and use it. Log in as a sysop and a regular user and check that viewing, creating and editing pages and uploading files still works. You will need to fix any problems reported either by PHP or MediaWiki itself.
[edit] See Also
[edit] Notes
- ↑ For an excellent tutorial on how to back up your database, see MySQL Tutorial MySQL Export: How to backup your MySQL database?
Language: | English • 日本語 |
---|