我最近在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);
Run Code Online (Sandbox Code Playgroud)
还有我的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);
}
Run Code Online (Sandbox Code Playgroud)
但是当我登录我的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
Run Code Online (Sandbox Code Playgroud)
在wordpress新:
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
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮我找出为什么会这样吗?
@ MAT-视觉:
正如用户RDrazard所指出的那样:在你的wp-local-config.php中,改变这两行:
define('WP_HOME','/client.dev');
define('WP_SITEURL','/client.dev');
Run Code Online (Sandbox Code Playgroud)
看起来像这样:
define('WP_HOME','http://localhost/client.dev');
define('WP_SITEURL','http://localhost/client.dev');
Run Code Online (Sandbox Code Playgroud)
我用我自己的本地WordPress安装测试了它,它清除了你得到的错误.希望你觉得这很有帮助!
我建议类似的东西,但为了避免硬编码你的网站我做的任何事情:
define('WP_HOME','http://' . $_SERVER['HTTP_HOST']);
define('WP_SITEURL','http://' . $_SERVER['HTTP_HOST']);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3397 次 |
| 最近记录: |