Php 如何将wordpress子网站从登台迁移到实时服务器(在wordpress multisite上)?

Php 如何将wordpress子网站从登台迁移到实时服务器(在wordpress multisite上)?,php,mysql,database,wordpress,web-deployment,Php,Mysql,Database,Wordpress,Web Deployment,我在wordpress多站点安装的wordpress站点上工作。现在,我正在从在实时服务器上开发切换到使用临时服务器,然后在一切完成后再推到实时服务器 当然,现在必须以某种方式为每个环境迁移和更新数据库(可能是两种方式;启动时拉到staging,部署时推到live)。但主题、模板和资产也必须迁移 因为我是新手,我不知道这通常是怎么做的。我正在寻找一个安全实用的解决方案。例如,我已经考虑过使用grunt(我已经在其他任务中使用了grunt),但它似乎并没有完成我想做的所有事情 所以我的问题是:我该

我在wordpress多站点安装的wordpress站点上工作。现在,我正在从在实时服务器上开发切换到使用临时服务器,然后在一切完成后再推到实时服务器

当然,现在必须以某种方式为每个环境迁移和更新数据库(可能是两种方式;启动时拉到staging,部署时推到live)。但主题、模板和资产也必须迁移

因为我是新手,我不知道这通常是怎么做的。我正在寻找一个安全实用的解决方案。例如,我已经考虑过使用grunt(我已经在其他任务中使用了grunt),但它似乎并没有完成我想做的所有事情

所以我的问题是:我该怎么做?如何在我的暂存服务器和live server之间安全轻松地同步wordpress子网站

  • 转到网络管理员,找到要移动的站点的ID(在下面的示例中–17)

  • 现在您需要传输整个
    wp content folder->uploads->Sites->site\u id
    (在这种情况下
    wp content folder->uploads->Sites->17
    ,当然您需要在新服务器上安装wp-请参阅附录)

  • 在访问网络上的原始站点时,检查它使用的主题。FTP到主站点
    wp content文件夹->主题
    并下载/传输它使用的主题。(或参见下文附录)

  • 对插件做同样的操作,转到原始站点仪表板,查看它使用的插件。不要忘了检查哪些插件在网络范围内被激活
    mu插件
    ,并将它们传输出去。出于兼容性的原因,我总是倾向于传输我以前使用过的,而不是从wp存储库下载。可以并且将在以后进行更新。目前,最好保持所有版本与原始版本相同

  • 导出/导入DB(例如使用PhpMyAdmin),然后重命名表:

  • (注意最后两个-这些是来自主网络数据库的表-不特定于站点)

  • 之后,我们执行正常的wp更新sql
  • 像这样:

    **
    To update WordPress options with the new blog location, use the following SQL command:
     note that this depends also on your folder structure ( wp in own folder here, not root )
    **/
    
    UPDATE wp_newsite_options SET option_value = replace(option_value, 'www.oldnetwork.com/multi', 'www.newsite.com/newsite') WHERE option_name = 'home' OR option_name = 'siteurl';
    
    /**
    After that you will need to fix URLs of the WordPress posts and pages, which translated from post slug, and stored in database wp_posts table as guid field. The URL values in this field are stored as absolute URLs instead of relative URLs, so it needs to be changed with the following SQL query:
    **/
    
    UPDATE wp_newsite_posts SET guid = replace(guid, 'www.oldnetwork.com','www.newsite.com/newsite');
    
    /**
    If you have linked internally within blog posts or pages with absolute URLs, these links will point to wrong locations after you move the blog location. Use the following SQL commands to fix all internal links to own blog in all WordPress posts and pages:
    **/
    
    UPDATE wp_newsite_posts SET post_content = replace(post_content, 'www.oldnetwork.com/multi', 'www.newsite.com/newsite');
    
    完成-之后-你的新网站应该很好

    但是-可能存在一些残留物(由于特定插件/主题),因此也可以搜索/替换
    originalname.com
    www.originalname.com
    sites/17

    这个过程,如果理解的话,可以很容易地调整(逆转)到另一个方向(从单个到多个)

    附录

    如果您有一个包含大量内容(如图像)的大型站点,FTP可能会花费太长时间。 直接在服务器上这样做要快得多,所以我只是在这里添加它

    • 登录到cpanel(或其他什么),文件管理器,然后对整个
      上传/site_id
      (17-记得吗?) 文件夹
    • 油灰
    (或新位置上的其他SSH)

    • 然后

      wget-mhttp://www.old-multi-domain-path/wp-content/uploads/sites/site-id.tar

    (或拉链,或rar等)

    您可能会在名为
    www.old-multi-domain-path/wp content/uploads/sites/site_id.tar

    现在,将其移动到root,并删除该文件夹

    rm-rf www.old-multi-domain-path/

    • 现在将wordpress ftp到新服务器上(或者如果您更愿意只使用最新版本,但由于兼容性问题,不建议使用最新版本。最好以后再升级)
    wgethttp://wordpress.org/latest.tar.gz


    现在回到第三阶段。

    为什么不通过简单的上传和直接的SQL查询来完成呢?@ObmerkKronen:我不知道,这是最简单的方法吗?您知道数据库中是否有我可以针对的子网站的特定前缀吗?或者它总是只是一个简单的搜索和替换?哇,这是一个非常彻底的答案。非常感谢。
    **
    To update WordPress options with the new blog location, use the following SQL command:
     note that this depends also on your folder structure ( wp in own folder here, not root )
    **/
    
    UPDATE wp_newsite_options SET option_value = replace(option_value, 'www.oldnetwork.com/multi', 'www.newsite.com/newsite') WHERE option_name = 'home' OR option_name = 'siteurl';
    
    /**
    After that you will need to fix URLs of the WordPress posts and pages, which translated from post slug, and stored in database wp_posts table as guid field. The URL values in this field are stored as absolute URLs instead of relative URLs, so it needs to be changed with the following SQL query:
    **/
    
    UPDATE wp_newsite_posts SET guid = replace(guid, 'www.oldnetwork.com','www.newsite.com/newsite');
    
    /**
    If you have linked internally within blog posts or pages with absolute URLs, these links will point to wrong locations after you move the blog location. Use the following SQL commands to fix all internal links to own blog in all WordPress posts and pages:
    **/
    
    UPDATE wp_newsite_posts SET post_content = replace(post_content, 'www.oldnetwork.com/multi', 'www.newsite.com/newsite');
    
    [\] #cd home/account-name/public_html