手册:移动一个维基

This page is a translated version of the page Manual:Moving a wiki and the translation is 58% complete.
Outdated translations are marked like this.
如果你只是想把你的维基从例如/var/www/html/移动到/var/www/html/mywiki/,请阅读这里的说明。

这个页面解释了如何将一个维基移到另一个服务器。当移动到不同的web服务器或域名(或两者都有)时,这通常是需要的。

最安全的方法是在两个维基上使用同一MediaWiki版本。 但是,在新服务器上安装较新的MediaWiki版本,并直接在新服务器上执行升级也是可行的。 事实上,如果想将维基升级到比旧服务器(如php版本)要求更高的新版本,这可能是您唯一的选择。

这些步骤在其他页面中有基本的解释:

  1. 备份你的维基
  2. 将备份从旧服务器传输至新服务器。
  3. 在新服务器上恢复备份
在开始备份维基之前,你可能希望将其设置为“只读”模式,以便在移动时没有人可以编辑它。 如果你不这样做,可能会丢失在迁移过程中所做的编辑、上传或日志等。 如需这么做,在LocalSettings.php中使用$wgReadOnly 。 例如:
$wgReadOnly = 'Down for maintenance: access will be restored shortly';

升级新服务器

如果你要在新服务器上升级到较新的MediaWiki版本,而不是将旧的MediaWiki目录和扩展名复制到新服务器上,你应该遵循升级流程。 你将在新服务器上下载MediaWiki的新版本和使用的扩展的新版本,以匹配新的MediaWiki版本。 记得运行升级程序

注释

  • 如果URL发生了变化(例如使用一个新域名),请确保在LocalSettings.php中更新对它的所有引用。 如需使用可视化编辑器(VisualEditor),你也需要更新Parsoid configuration
    • 缓存页面上的链接可能仍然指向旧域名。 这时,你可能需要增加$wgCacheEpoch来丢弃缓存的页面。
  • Check that the upload/ directory 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 extensions)
  • When manually transferring a wiki from a windows platform to a Linux platform the best method is to:
  1. Manually install MediaWiki on the Linux platform from a tar file as outlined here: Manual Install of Wiki (i.e., try not to use install from an automated package)
  2. Replace the newly installed MediaWiki folder (e.g., /var/www/mediawiki...) on your Linux machine with the MediaWiki base folder from your windows machine
  3. Update 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:
  1. You might need to repair Searchindex: 在phpMyAdmin中,输入"REPAIR TABLE wikidb.searchindex; "用于重建搜索索引。 wikidb是你的数据库的名称。
  2. The collation of some rows may be changed. Cross-check it with the original database.

Test

此时,尝试在新服务器上使用维基。 以系统管理员和普通用户的身份登录,检查查看、创建和编辑页面以及上传文件是否仍然有效。 修复PHP或MediaWiki本身报告的任何问题。

在将旧的维基置于只读模式之前,您可以执行整个过程来测试移动是否可以正常工作。 一旦您知道新服务器中的维基按预期工作,您就可以将旧维基置于只读模式并再次执行移动。

常见问题

Inaccessible files after 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`;

参见


外部链接


注释