我最近在 Windows 7 上使用 XAMP 在本地设置了 Wordpress。我为我的安装创建了一个 SQL 数据库,并设置了一些配置文件来处理实时服务器和本地,以便在我开始使用 git 时使用。
我有一个wp-local-config.php:
<?php
// Local server settings
// Local Database
define('DB_NAME', '<mysiteuser>');
define('DB_USER', '<mydbuser>');
define('DB_PASSWORD', '<db password>');
define('DB_HOST', 'localhost');
// Overwrites the database to save keep edeting the DB
define('WP_HOME','/client.dev');
define('WP_SITEURL','/client.dev');
// Turn on debug for local environment
define('WP_DEBUG', true);
还有我的wp-config.php
<?php
// Use these settings on the local server
if ( file_exists( dirname( __FILE__ ) . '/wp-local-config.php' ) ) {
include( dirname( __FILE__ ) . '/wp-local-config.php' );
// Otherwise use the below settings (on live server)
} else {
// Live Server Database Settings
define( 'DB_NAME', '<live db name>');
define( 'DB_USER', '<live db user>');
define( 'DB_PASSWORD', '<live db pw>' );
define( 'DB_HOST', 'localhost' );
// Overwrites the database to save keep edeting the DB
define('WP_HOME','http://<client url>');
define('WP_SITEURL','http://<client url>');
// Turn Debug off on live server
define('WP_DEBUG', false);
}
然而,当我登录到我的 wordpress 安装时,我收到很多调试错误,例如:
(在屏幕顶部)
Notice: Undefined index: host in C:\xampp\htdocs\client.dev\wp-includes\theme.php on line 1820
Notice: Undefined index: host in C:\xampp\htdocs\client.dev\wp-includes\theme.php on line 1820
Notice: Undefined index: host in C:\xampp\htdocs\client.dev\wp-includes\theme.php on line 1876
Notice: Undefined index: host in C:\xampp\htdocs\client.dev\wp-includes\theme.php on line 1876
在 wordpress new 中:
Notice: Undefined index: host in C:\xampp\htdocs\client.dev\wp-includes\http.php on line 470
Notice: Undefined index: host in C:\xampp\htdocs\client.dev\wp-includes\class-http.php on line 129
谁能帮我找出为什么会这样?
最佳答案
@Mat-visual:
正如用户 RDrazard 指出的:在您的 wp-local-config.php 中,更改这两行:
define('WP_HOME','/client.dev');
define('WP_SITEURL','/client.dev');
看起来像这样:
define('WP_HOME','http://localhost/client.dev');
define('WP_SITEURL','http://localhost/client.dev');
我用自己在本地安装的 WordPress 对此进行了测试,它清除了您遇到的错误。希望对您有所帮助!
关于mysql - Xampp 服务器上的 Wordpress — 未定义索引 : host,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22998169/