调试 WordPress 网络
如果您到达此页面,您很可能在您的 WordPress 网络 中收到了错误。当 WordPress 无法在数据库中查找网络的其中一个或多个全局表时,就会发生此故障。
在某些共享主机上,主机已禁用运行该功能。在 创建网络 之前 最好与您的 Web 主机联系,以确保您的 Web 主机账户满足技术要求。
如果您刚刚安装了网络
检查您的 wp-config.php 文件:
- 正确的数据库详细信息
SUBDOMAIN_INSTALL常量MULTISITE常量$base变量- 表前缀
您不应在以下代码之后有任何内容:
/* That's all, stop editing! Happy blogging. */
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');
将任何位于以下代码之后的代码移动:
require_once(ABSPATH . 'wp-settings.php');
到停止编辑行之上。
Mod_rewrite 不起作用
主站点可以工作,但在尝试访问添加的子域子站点时会出现 404 错误。带有 Apache HTTPD 安装的 Ubuntu 需要这些步骤:
sudo a2enmod rewrite
sudo nano /etc/apache2/sites-avail/default
并在两处将 'AllowOverride None' 更改为 'AllowOverride all'
/etc/init.d/apache2 restart
以重启 apache2。请注意,在较新版本的 Ubuntu 中,以下语法更受青睐(用于重启服务,如 Apache – 另外请注意,在这两种情况下您可能需要使用 prepend sudo):
service apache2 restart
检查数据库
假设上述内容都正确,请检查数据库本身,看看是否创建了 所有额外的网络表。这些表是:
- wp_blogs
- wp_blogmeta
- wp_blog_versions
- wp_registration_log
- wp_signups
- wp_site
- wp_sitemeta
如果您拥有这些数据库表或已手动添加它们,但 wp_site 和/或 wp_blogs 为空,您可能需要运行一些 SQL 查询来为主站点插入行。请务必调整以下查询中的表前缀、域、日期、用户名和其他部分以匹配您的安装。
INSERT INTO wp_site VALUES ( 1, 'domain.com', '/' );
# change domain.com to the full domain of your original site and / to the path
INSERT INTO wp_blogs VALUES( 1, 1, 'domain.com', '/', '2015-01-01', '2015-01-01', 1, 0, 0, 0, 0, 0 );
# change domains.com and / to domain and path of your site. Change dates if you want.
INSERT INTO wp_sitemeta VALUES( 1, 1, 'site_admins', 'a:1:{i:1;s:5:"admin";}' );
# Sets the admin user as a Super Admin. Change "admin" to your user_login.
# Change "s:5" to "s:#" where # is the number of characters in user_login.
如果新站点创建突然停止工作
请查看您的数据库如上所述。再次确认数据库服务器的位置是否未更改,或者已更改,您已更新了 wp-config.php 文件。
其他鲜为人知的问题
检查数据库用户是否具有数据库的所有权限。
此外,在从 WordPressMU 升级到 3.0 及更高版本的极少数情况下,一些用户在创建新站点并收到错误时遇到了问题。事实证明这是一个数据库排序规则问题。
检查 .htaccess 指令是否在 Apache 日志中抛出错误。
像这样:
Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden:
This will result in a Network install appearing to fail and may show WP errors like
One or more database tables are unavailable. The database may need to be repaired.