高级管理文档

将 WordPress 站点迁移到 WordPress 多站点网络

💡 云策文档标注

概述

本教程指导如何将多个独立的 WordPress 安装迁移到一个 WordPress 多站点网络中,支持迁移使用自有域名或主域名子域名的站点。教程基于 cPanel 服务器环境,其他服务器管理方案需调整步骤。

关键要点

  • 迁移前需备份整个站点,包括通过 FTP 复制文件以访问插件和主题。
  • 从每个现有 WordPress 安装中导出 WXR 文件,包含所有文章和页面,注意禁用插件以避免导出冲突。
  • 安装 WordPress 并激活多站点功能,选择子域名选项,编辑 wp-config.php 文件。
  • 为每个要导入的站点创建博客,注意命名以避免管理员重定向问题。
  • 在每个博客的后台导入对应的 WXR 文件,映射作者并确保附件正确导入。
  • 复制主题和插件文件到新 wp-content 目录,检查插件兼容性,激活主题可针对网络或单个站点。
  • 编辑每个站点的配置设置、小部件等,使其外观与迁移前一致。

注意事项

  • PHP 配置可能限制 WXR 文件上传大小或内存,需调整 max_upload_size 和内存限制。
  • 将附加域名转换为停放域名时,会删除关联的域名和电子邮件转发器,需注意恢复。
  • 导入用户时可能遇到角色和信息丢失问题,需手动处理。
  • 如果旧站点不可用,可通过 Google 缓存或 Internet Archive Wayback Machine 找回设置。

📄 原文内容

This tutorial explains how to migrate multiples WordPress installs to a WordPress multisite install. You can migrate sites that use their own domain names, as well as sites that use a subdomain on your primary domain.

This tutorial assumes that you are hosting WordPress on a server using cPanel. If you are using another solution to manage your server, you’ll have to adapt these instructions.

Steps to follow

Backup your site

Generate a full site backup in cPanel. It might also help to copy all the files on the server via FTP, so that you can easily access the files for plugins and themes, which you’ll need in a later step.

Export from your existing WordPress installs

In each of your existing WordPress installations, go Tools > Export in WordPress. Download the WXR files that contain all your posts and pages for each site. See the instructions on the Tools Export Screen.

Make sure that your export file actually has all the posts and pages. You can verify this by looking at the last entry of the exported file using a text editor. The last entry should be the most recent post.

Some plugins can conflict with the export process, generating an empty file, or a partially complete file. To be on the safe side, you should probably disable all plugins before doing the exports.

It’s also a good idea to first delete all quarantined spam comments as these will also be exported, making the file unnecessarily large.

Note: widget configuration and blog/plugin settings are NOT exported in this method. If you are migrating within a single hosting account, make note of those settings at this stage, because when you delete the old domain, they will disappear.

Install WordPress

Install WordPress. Follow the instructions for Installing WordPress.

Activate multisite

Activate multi-site in your WordPress install. This involves editing wp-config.php a couple of times. You need to use the subdomain, not the subdirectory, option. See the instructions on how to Create A Network.

Create blogs for each site you want to import

Create blogs for each of the sites you want to host at separate domains. For example, importedblogdotorg.mydomain.com.

Note: choose the name carefully, because changing it causes admin redirection issues. This is particularly important if you are migrating a site within the same hosting account.

Import WXR files for each blog

Go to the backend of each blog, and import the exported WXR file for each blog. Map the authors to the proper users, or create new ones. Be sure to check the box that will pull in photos and other attachments. See the instructions on Tools Import SubPanel.

Note: if you choose to import images from the source site into the target site, make sure they have been uploaded into the right place and are displayed correctly in the respective post or page.

Copy theme and plugin files

Before you start, check that your plugins will work in the network installation. If a plugin is not supported, do not install it. Find suitable alternatives for it by searching for the plugin’s function with “multisite” or even “mu”, as in “social bookmarking plugin wordpress multisite”.

Copy the theme and plugin files from your old WP installs to their respective directories in the new wp-content. You can activate themes for the network, or you can go to Superadmin > Sites, then click edit on the site you want, and enable a given theme for just that site.

Note: if you are using a child theme, copy both parent and child themes to the new site.

Edit WordPress configuration settings for each site

Edit the configuration settings, widget, etc. for each site. By the end of this step, each site should look exactly as it did before, only with the URL subdomain.example.com or example.com/subsite rather than its correct, final URL.

Potential problems

Limitations of PHP configuration

You may run into trouble with the PHP configuration on your host. There are two potential problems. One is that PHP’s max_upload_size will be too small for the WXR file. The other problem is that the PHP memory limit might be too small for importing all the posts.

There are a couple ways to solve it. One is to ask your hosting provider to up the limits, even temporarily. The other is to put a php.ini file in your /wp-admin/ and /wp-includes directories that ups the limits for you (php.ini files are not recursive, so it has to be in those directories). Something like a 10 MB upload limit and a 128 MB memory limit should work, but check with your hosting provider first so that you don’t violate the terms of your agreement.

Search the WordPress forum support for help with PHP configuration problems.

Converting add-on domains to parked domains

Deleting add-on domains in cPanel and replacing them with parked domains will also delete any domain forwarders and e-mail forwarders associated with those domains. Be aware of this, so that you can restore those forwarders once you’ve made the switch.

Limitations of importing users

As there is the above way to import the content into an instance of the Multisite-blog, you are running into massive troubles, when it gets to import multiple users. Users are generated during the import, but you won’t get any roles or additional information into the new blog.

Losing settings

If the old site is no longer available and you find you have forgotten to copy some setting or you want to make sure you have configured everything correctly, run a google search for your site and then click to view the cached version. This option is available only until your new site has been crawled, so you’d better be quick.

Another option might be the Internet Archive Wayback Machine. They may have a copy of the site (or some part of it) archived.