WordPress配置文件¶
配置文件wp-config.php¶
wp-config.php文件是WordPress的配置文件,会在安装WordPress时自动生成,里面的信息包含了当前网站的MySQL数据库的配置信息,以及其他用途。
数据库部分¶
/** WordPress数据库名 */
define( 'DB_NAME', 'database_name_here' );
/** MySQL 数据库用户名 */
define( 'DB_USER', 'username_here' );
/** MySQL 数据库密码 */
define( 'DB_PASSWORD', 'password_here' );
/** MySQL 主机 */
define( 'DB_HOST', 'localhost' );
/** 创建数据库的默认文字编码. */
define( 'DB_CHARSET', 'utf8' );
/** 数据库整理类型,勿改. */
define( 'DB_COLLATE', '' );
安全密钥¶
由WordPress自动生成
define( 'AUTH_KEY', 'put your unique phrase here' );
define( 'SECURE_AUTH_KEY', 'put your unique phrase here' );
define( 'LOGGED_IN_KEY', 'put your unique phrase here' );
define( 'NONCE_KEY', 'put your unique phrase here' );
define( 'AUTH_SALT', 'put your unique phrase here' );
define( 'SECURE_AUTH_SALT', 'put your unique phrase here' );
define( 'LOGGED_IN_SALT', 'put your unique phrase here' );
define( 'NONCE_SALT', 'put your unique phrase here' );
数据库表格前缀¶
如果数据库要支持多个网站使用,就需要修改前缀;修改前缀,也可以降低数据库受到攻击的可能性
$table_prefix = 'wp_';
开发者调试¶
define('WP_DEBUG', false);
WP_DEBUG:查看 WordPress错误提示,默认关闭,把 false 修改成 true 就能打开错误提示功能。
遇到的问题¶
不能写入wp-config.php文件
安装WordPress 出现“抱歉,不能写入wp-config.php文件”的主要原因是该文件没有写入权限
- 网站根目录先把数据库信息填写进 wp-config-sample.php文件,然后改名为 wp-config.php并上传到网站根目录。
- 服务器修改权限文件权限到 755 或者 777看能否解决问题
无法正确连接数据库
安装 WordPress的默认数据库主机地址是 localhost,偶尔会遇到报错无法正确连接数据库,出现这种情况把localhost改成127.0.0.1 差不多就能解决了