你如何在本地运行wordpress多站点?

时间:2015-11-11 17:34:06

标签: php wordpress

我正在尝试使用MAMP在本地运行Wordpress MultiSite配置。

我复制了数据库和php文件。

然后我将主域名更改为localhost:8888并关闭子域名:

define('DOMAIN_CURRENT_SITE', 'localhost:8888');
define('SUBDOMAIN_INSTALL', false);

我一直收到错误“无法连接到数据库”。

当我去localhost时:8888 / wp-admin我得到了一个更详细的错误,我的域名在new2_wp_blogs找不到。所以我进入数据库并将所有网站的域名切换到localhost:8888以及前往子域名的路径。

我也进入wp_options并将siteurlhome更改为http://localhost:8888

现在,当我转到localhost:8888主网站时,

当我访问我的第一个子网站时,我被重定向到localhost/<nameofsite>

当我转到localhost:8888/wp-admin时,我被重定向到:

http://localhost:8888/%3Cbr%20/%3E%3Cb%3ENotice%3C/b%3E:%20%20Use%20of%20undefined%20constant%20PWP_NAME%20-%20assumed%20'PWP_NAME'%20in%20%3Cb%3E/Users/anatoliyzaslavskiy/Sites/even-wp/wp-content/mu-plugins/mu-plugin.php%3C/b%3E%20on%20line%20%3Cb%3E101%3C/b%3E%3Cbr%20/%3Ehttp://localhost:8888/wp-login.php?wpe-login=PWP_NAME

2 个答案:

答案 0 :(得分:0)

一个简单的解决方法是在hosts file中创建条目(对于windows: <div ng-switch on="list.type"> <ul ng-switch-when="unorder"> <li ng-repeat="item in items"> {{ item.text }} </li> </ul ng-switch-when="unorder"> <ol ng-switch-when="order"> <li ng-repeat="item in items"> {{ item.text }} </li> </ol ng-switch-when="order"> </div> ,对于linux:%SystemRoot%\System32\drivers\etc\hosts)。为此,您选择的域名不使用真正的顶级域名,例如wordpress.local并在主机文件中添加多站点示例列表:

/etc/hosts

现在,您可以将127.0.0.1 wordpress.local 127.0.0.1 www.wordpress.local 127.0.0.1 test.wordpress.local 127.0.0.1 example.wordpress.local 127.0.0.1 more.wordpress.local 用于多站点域。当然,您需要配置apache来处理这些主机。

答案 1 :(得分:0)

If you already have a live website and just want to create a sandbox version on localhost, then instead of manually migrating the site you can use plugins like duplicator which takes care of all the migration issues and gives you a nice installer to use.

While duplicator doesn't support multi site yet but here is another plugin that has support for multisite https://wordpress.org/plugins/ns-cloner-site-copier/