字preSS:从服务器移动多站点为localhost [英] Wordpress: Move Multisite from server to localhost

查看:190
本文介绍了字preSS:从服务器移动多站点为localhost的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想移动部署的字preSS多站点为当地的环境。我备份服务器数据库和文件。在我的本地环境中,我创建了一个新的数据库并导入备份。我也复制服务器的文件到我的本地机器上。

I am trying to move a deployed WordPress Multi-Site to a local environment. I backed up the server database and files. In my local environment, I created a new database and imported the backup. I also copied the server files to my local machine.

我所做的这些步骤:

  1. 我改变了的wp-config.php文件并更新它与新的 DB-名称分贝-username DB-密码,并设置定义(DOMAIN_CURRENT_SITE','www.mysitename.com'); 定义(DOMAIN_CURRENT_SITE','本地主机/ mysitename');

  1. I changed wp-config.php and updated it with the new db-name, db-username, db-password and set define('DOMAIN_CURRENT_SITE', 'www.mysitename.com'); to define('DOMAIN_CURRENT_SITE', 'localhost/mysitename');.

我在 WP-选项改为请将option_value 数据库表为指向我的本地地址。

I changed option_value in the wp-option database table to point to my local address.

我也删除了这些行的.htaccess

# Redirect non-www urls to www
RewriteCond %{HTTP_HOST} !^www\.mysitename\.com
RewriteRule (.*) http://www.mysitename.com/$1 [R=301,L]

但是,当我去为 127.0.0.1/mysitename 我得到这个错误:此网页有重定向循环

But when I go to 127.0.0.1/mysitename I get this error: This webpage has a redirect loop.

当我更改定义(DOMAIN_CURRENT_SITE','本地主机/ mysitename'); 定义(DOMAIN_CURRENT_SITE','localhost'的) ; 和我去的 127.0.0.1/mysitename 解决它让我看到的的phpinfo()的页

And when I change define('DOMAIN_CURRENT_SITE', 'localhost/mysitename'); to define('DOMAIN_CURRENT_SITE', 'localhost'); and I go to 127.0.0.1/mysitename address it shows me the phpinfo() page.

我怎样才能解决我的问题?

How can I fix my problem?

请解释一下,如果我必须设置一些在的.htaccess 的wp-config.php文件文件。

Please explain if I must set something in .htaccess and wp-config.php files.

感谢你了。

推荐答案

我想不出来允许与协议本地主机连接上(http://),所以如果你看到上(http:)本地主机把它读作HTTP://本地主机/。如果有人可以编辑这对我来说这将是伟大的!

I couldn't figure out of to allow localhost links with protocol (http://) so if you see "(http:)localhost" read it as http:// localhost/. If someone could edit this for me that would be great!

  1. 备份从本地主机数据库中。
  2. 创建新的服务器上新的数据库,在这里导入导出数据库。
  3. 上传所有Word preSS-文件到服务器。
  4. 编辑的wp-config.php文件,修改数据库名,用户名和密码。通常低于定义(WP_DEBUG'..我定义WP_HOME和WP_SITEURL,这将覆盖字preSS数据库设置为路径根。 DOMAIN_CURRENT_SITE用于多站点安装。所以,如果它不是一个多站点,不要用这个,如果它是一个多点,就用这个,而不是WP_HOME和WP_SITEURL。

  1. Backup your database from localhost.
  2. Create new database on new server, import the exported database here.
  3. Upload all Wordpress-files to the server.
  4. Edit wp-config.php, changed database name, username and password. Usually below "define('WP_DEBUG'.. I define "WP_HOME" and "WP_SITEURL", these will override Wordpress database settings for path to root. "DOMAIN_CURRENT_SITE" is used for multisite installations. So if it isn't a multisite, don't use this, if it is a multisite, just use this and not WP_HOME and WP_SITEURL.

define('WP_HOME', 'http://mysitename.com');
define('WP_SITEURL', 'http://mysitename.com');

  • 如果您上传从本地主机藏汉的.htaccess,从服务器中删除。

  • If you uploaded .htaccess from localhost aswell, delete it from the server.

    和你就大功告成了!无需费心做的数据库更改。对于本地主机安装,只需定义WP_HOME和WP_SITEURL为localhost代替。

    And you're done! No need to bother doing database changes. For your localhost installation, just define WP_HOME and WP_SITEURL to localhost instead.

    Multisites在Word preSS是在屁股迁移一种痛苦,它涉及到多个数据库的变化,甚至当你做的一切正确的,似乎只有工作的一些时代没有错误。然而,这些都是建议的步骤:

    Multisites in Wordpress is a pain in the ass to migrate, it involves several database changes and even when you made everything correct it seems to only work some of the times without errors. However these are the recommended steps:

    1. 导出数据库,与上面相同。
    2. 在上传新的数据库,同上。
    3. 添加所有您的Word preSS文件,与上面相同。
    4. 编辑您的wp-config.php文件与新的数据库信息,添加以下定义:

    1. Export database, same as above.
    2. Upload new database, same as above.
    3. Add all your Wordpress files, same as above.
    4. Edit your wp-config.php with the new database info, add the following defines:

    define('MULTISITE', true);
    define('SUBDOMAIN_INSTALL', false); // true or false depending if the paths for each multisite is pointed by a subdomain.
    define('DOMAIN_CURRENT_SITE', 'localhost'); // localhost is the DOMAIN of the new location, so even if the ABS_PATH is localhost/whatever, you should have localhost here.
    define('PATH_CURRENT_SITE', '/');
    define('SITE_ID_CURRENT_SITE', 1);
    define('BLOG_ID_CURRENT_SITE', 1);
    

  • 您应该具备所有这些在wp-config.php文件您要导出的网站,所以只需要从那里拷贝,粘贴,编辑DOMAIN_CURRENT_SITE。

    You should have all of these in the wp-config.php of the site you are trying to export, so just copy-paste them from there, and edit DOMAIN_CURRENT_SITE.

    1. 编辑您的htaccess像这样(的RewriteBase /路径/应该是相对路径,也就是说,如果你的网站是位于本地主机/ MYPAGE它应该是的RewriteBase /我的空间/):

    1. Edit your htaccess like this (Rewritebase /path/ should be relative path, ie if your website is located at localhost/mypage it should be "RewriteBase /mypage/"):

    # MultiSite
    RewriteEngine On
    RewriteBase /subfolder-from-localhost/
    RewriteRule ^index\.php$ - [L]
    
    # add a trailing slash to /wp-admin
    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]
    

  • 数据库编辑时!这些步骤需要为每一个做子站点的多点了,如果我输入更改表wp_site,你应该复制它在wp_site1 / wp_site2等...

  • Database edit time! These steps needs to be done for every subsite your multisite has, if I type change table "wp_site", you should replicate it in wp_site1/wp_site2 etc...

    在表wp_options:变化领域SITE_URL和家(HTTP:)。本地主机/子文件夹(没有尾随斜线)

    In table wp_options: change fields "site_url" and "home" to (http:)localhost/subfolder (no trailing slash).

    在表wp_blogs:改变域为localhost和路径为每个子网站/子文件夹/每个条目(必须有斜杠)

    In table wp_blogs: change "domain" to "localhost", and "path" for every entry for each subsite to /subfolder/ (must have trailing slash)

    在表wp_site:改变域为localhost和路径来/子文件夹/(必须有斜杠)

    In table wp_site: change "domain" to "localhost", and "path" to /subfolder/ (must have trailing slash)

    在表wp_sitemeta:变SITEURL为完整的路径,即上(http:)本地主机/子文件夹/(必须有斜杠)

    In table wp_sitemeta: change "siteurl" to full path ie (http:)localhost/subfolder/ (must have trailing slash)

    1. 现在你应该ATLEAST可以访问你的页面,如果你仍然得到重定向循环或死亡的白色屏幕,仔细检查数据库更改。现在,登录到管理,我们需要改变一些硬codeD网址数据库中,我通常做了一个名为SEACH和替换插件,所以下载并安装这个插件,并通过输入什么它使用它应搜索(旧的URL)以及如何取代它(新的URL)。

    1. Now you should atleast have access to your page, if you still get redirection loop or white screen of death, double check the database changes. Now login to admin, and we need to change some hardcoded URLs in the database, I usually do this with a plugin called "Seach and replace", so download and install this plugin, and use it by typing in what it should search for (old url) and what to replace it with (new url).

    Search for: http://mysitename.com
    Replace with: (http:)localhost
    

  • 现在希望你拥有多站点的功能迁移。正如我指出我这样做了几次,它几乎看起来随机,如果一切正常与否。我说我已经成功使用这种方法也许6出的8倍。

  • Now hopefully you have a functional migration of the multisite. As I noted I've done this a couple of times, and it almost seems random if everything works or not. I'd say I had success with this approach perhaps 6 out of 8 times.

    编辑:新增如何迁移多站点

    Added how to migrate multisite.

    这篇关于字preSS:从服务器移动多站点为localhost的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆