简体   繁体   English

如何将Wordpress子站点从登台迁移到实时服务器(在Wordpress多站点上)?

[英]How do I migrate a wordpress subsite from a staging to a live server (on wordpress multisite)?

I work on wordpress sites with a wordpress multisite install. 我在使用wordpress多站点安装的wordpress网站上工作。 Now I'm switching from developing on the live server, to working with a staging server and then pushing to the live server when everything is done. 现在,我从在实时服务器上进行开发过渡到使用暂存服务器,然后在一切完成后将其推送到实时服务器。

Now of course the database would have to be migrated and updated for each environment in some way (probably both ways; pulled to staging for starting and pushed to live for deployment). 现在,当然,现在必须以某种方式(可能两种方式)迁移和更新每个环境的数据库(可能需要两种方式;必须拉到暂存阶段才能启动,然后又要上线进行部署)。 But also the themes, templates and assets would have to be migrated. 但是主题,模板和资产也必须迁移。

Since I'm new to this, I don't know exactly how this is usually done. 由于我是新手,所以我不知道通常如何完成。 I'm looking for a safe and practical solution. 我正在寻找安全实用的解决方案。 I've looked into using grunt (which I already use for other tasks) with grunt-wordpress-deploy for example, but it doesn't seem to be doing everything I want to do. 例如,我已经考虑将grunt(我已经用于其他任务)与grunt-wordpress-deploy一起使用,但是它似乎并没有完成我想做的所有事情。

So my question is: how do I do this? 所以我的问题是:我该怎么做? How do I safely and easily synchronize a wordpress subsite between my staging and my live server? 如何在暂存器和实时服务器之间安全,轻松地同步wordpress子站点?

  1. Go to network admin and find the ID of site you want to move ( In the examples below – 17 ) 转到网络管理员,找到要移动的站点的ID(在以下示例中– 17)

  2. Now you would want to transfer the whole wp-content folder -> uploads -> Sites -> site_id ( in this case wp-content folder -> uploads -> Sites -> 17 , of course you need to have wp on new server - see addendum ) 现在,您需要传输整个wp-content folder -> uploads -> Sites -> site_id (在这种情况下, wp-content folder -> uploads -> Sites -> 17 ,当然,您需要在新服务器上安装wp-见附录)

  3. In to the original site on the network, check what theme it uses . 在网络上的原始站点中,检查其使用的主题。 FTP to the main site wp-content folder -> Themes and download/ transfer the theme it uses . FTP到主站点wp-content folder -> Themes然后下载/传输其使用的主题。 ( or see below addendum ) (或参见下面的附录)

  4. Do the same for plugins , go to the original site dashboard, see what plugins it uses . 对插件执行相同的操作,转到原始站点的仪表板,查看其使用了哪些插件。 Do not forget to also check what plugins are activated NETWORK WIDE and mu-plugins and transfer those too . 别忘了还要检查哪些插件已激活NETWORK WIDEmu-plugins并进行转移。 For compatibility reasons , I always prefer to transfer the ones I used before and not to download from the wp repository . 出于兼容性原因,我总是更喜欢转移以前使用的内容,而不是从wp信息库下载。 updates can and will be made later . 可以并且将在以后进行更新。 for now , it is better to keep all the versions the same as original . 目前,最好将所有版本与原始版本保持相同。

  5. Export / Import DB ( using PhpMyAdmin for example ) and then rename the tables : 导出/导入数据库(例如使用PhpMyAdmin),然后重命名表:

( note the last two - those are tables from the MAIN network DB - not site specific ) (请注意最后两个-这些是来自MAIN网络数据库的表-并非特定于站点)

Rename table wp_multi17_commentmeta to wp_newsite_commentmeta;
Rename table wp_multi17_comments to wp_newsite_comments;
Rename table wp_multi17_links to wp_newsite_links;
Rename table wp_multi17_options to wp_newsite_options;
Rename table wp_multi17_postmeta to wp_newsite_postmeta;
Rename table wp_multi17_posts to wp_newsite_posts;
Rename table wp_multi17_terms to wp_newsite_terms;
Rename table wp_multi17_term_relationships to wp_newsite_term_relationships;
Rename table wp_multi17_term_taxonomy to wp_newsite_term_taxonomy;
Rename table wp_multiuermeta to wp_newsite_usermeta;
Rename table wp_multiusers to wp_newsite_users;
  1. After that , we execute the normal wp update sql 之后,我们执行常规的wp update sql

like so : 像这样:

**
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');

DONE - After that - Your new site should be fine . 完成-之后-您的新站点应该没问题。

However - some residues might be there ( due to specific plugins / themes ) , so search/replace for originalname.com or www.originalname.com or sites/17 could also be made .. 但是-可能会有一些残留(由于特定的插件/主题),因此也可以搜索/替换originalname.comwww.originalname.comsites/17

This process, when understood - can easily be adapted ( reversed ) to transfer also the other way around ( from single to multi ) 当理解该过程时,可以很容易地对其进行调整(逆向),以另一种方式(从单到多)进行转换。

Addendum 附录

If you have a LARGE site with a lot of content ( eg images ) - FTP might take too long . 如果您的大型站点内容很多(例如图像),则FTP可能花费太长时间。 It would be much faster to do that on the server directly, so I am just adding it here . 直接在服务器上执行此操作会更快,所以我在这里添加它。

  • log in to cpanel ( or whatever ), files manager , and tar the whole uploads/site_id (17 - remember ? ) folder 登录到cpanel(或其他任何文件),文件管理器和tar,将整个uploads/site_id (17-还记得吗?)文件夹
  • in PUTTY 在腻子

( or other SSH on your new location ) (或新位置上的其他SSH)

[\] #cd home/account-name/public_html
  • then 然后

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

( or zip, or rar etc … ) (或zip或rar等…)

you will probably get the file at a folder called www.old-multi-domain-path/wp-content/uploads/sites/site_id.tar 您可能会在名为www.old-multi-domain-path/wp-content/uploads/sites/site_id.tar的文件夹中获取文件

now , move it to root, and delete the folder 现在,将其移至根目录并删除该文件夹

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

  • now ftp wordpress to the new server ( or if you prefer to just take the newest version - but it is not reccomanded for compatibility issues . better do upgrades later ) 现在将ftp wordpress传送到新的服务器(或者如果您只想使用最新版本-但不考虑兼容性问题,最好以后进行升级)

wget http://wordpress.org/latest.tar.gz

Now go back up to Phase 3. 现在回到阶段3.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM