Mediawiki migration

From Bjoern Hassler's website
Jump to: navigation, search

Some quick notes on migrating a mediawiki to a fresh server, like for like, without upgrade or changes. Also see https://www.mediawiki.org/wiki/Manual:Moving_a_wiki

1 On the old server[edit]

  • Locate the mediawiki installation, say in /var/www/w. Look around if there is any thing else you need, e.g. in /var/www/, .e.g
    • .htaccess
    • your logo
    • your favicon
    • robots.txt
  • Dump the database as described on the mediawiki help pages: https://www.mediawiki.org/wiki/Manual:Backing_up_a_wiki

This shouldn't really be necessary, but you may want to check what privileges your mysql user has

mysql> show grants;
+-------------------------------------------------------------------------+
| Grants for YOUR_USER@localhost                                                          
+-------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'YOUR_USER'@'localhost' IDENTIFIED BY PASSWORD <secret>
| GRANT ALL PRIVILEGES ON `YOUR_DB`.* TO 'YOUR_USER'@'localhost'                   
+-------------------------------------------------------------------------+

2 On the new server[edit]

See https://www.mediawiki.org/wiki/Manual:Restoring_a_wiki_from_backup. You'll need to know your mysql user name and password. We assume that your wiki uses mysql, and that you have root access to mysql (typically mysql user called "root" and password).

Transfer the files from /var/www/ and the dump_of_wikidb.sql file to the new sever. Check your LocalSettings.php for your database user (wikidb_user), and the password (wikidb_userpassword) and your database table (wikidb). We'll need to re-create this user

mysql -u root -p

Enter your password, and you're at the mysql prompt:

mysql>

At the prompt:

CREATE DATABASE wikidb;
CREATE USER wikidb_user IDENTIFIED BY 'wikidb_userpassword';
USE wikidb;
GRANT SELECT, UPDATE, INSERT, DELETE, ALTER, CREATE, INDEX, USAGE ON wikidb.* TO wikidb_user;

Now, if you have SemanticMediaWiki installed, the wikidb_users needs some more permissions (https://www.semantic-mediawiki.org/wiki/Help:Installation):

GRANT CREATE TEMPORARY TABLES and DROP ON wikidb.* TO wikidb_user;

You now have a non-root user, which the wiki files can use.

Import the database:

mysql -u wikidb_user -p wikidb < dump_of_wikidb.sql

(I needed to do this as -u root)

You've now got the database restored. Put the files into your new /var/www.

2.1 Issues encountered[edit]

2.1.1 SemanticMediaWiki[edit]

Would run - db user needed more privileges, see above.

2.1.2 Enable debugging[edit]

If something doesn't work, enable debugging to see what the issue is:

error_reporting( -1 );
ini_set( 'display_errors', 1 ); 
$wgShowExceptionDetails=true;
$wgDebugToolbar=true;
$wgShowDebug=true;
$wgDevelopmentWarnings=true;

2.1.3 File permissions[edit]

Depending on how you've done the transfer, you may need to change some files so that your webserver process (e.g. user www-data) can access files. This certainly applies to

/var/www/w/images

but there may be other places required by extensions that need to be made writable:

/var/www/w/extensions/Widgets/compiled_templates/

Also, various users may maintain the wiki, so you may need to give them access too.

2.1.4 to investigate[edit]

$wgServer
$wgServerName

2.1.5 caching[edit]

Turned caching off, as the new server missed APC. Need to install APC.

2.2 DNS[edit]

Point DNS records from the old server to the new server.