前言
本文重点介绍wp-config.php中的部分配置解析, 其余配置文件随缘更新
WP-Config.php
ssl部分
1 2 3 4
| # 强制开启ssl $_SERVER['HTTPS'] = 'on'; define('FORCE_SSL_LOGIN', true); define('FORCE_SSL_ADMIN', true);
|
当nginx配置强制ssl时, 必须同时配置wp为强制ssl, 且设置站点后台地址为 https://yourdomain.com
mysql部分
1 2 3 4 5 6 7
| define( 'DB_NAME', 'mysql' ); define( 'DB_USER', 'user' ); # 用户名 define( 'DB_PASSWORD', 'password' ); # 密码 define( 'DB_HOST', 'address:port' ); # 连接地址和端口, 单IP时默认端口为3306 define( 'DB_CHARSET', 'utf8mb4' ); # 可选 define( 'DB_COLLATE', '' ); # 可选 # 更安全的连接方式 # define('DB_HOST', 'localhost:/run/mysqld/mysqld10.sock');
|
MariaDB和MySQL配置通用, 可直接照搬
redis部分
1 2 3 4
| define('WP_REDIS_HOST', 'address'); # 连接地址 define('WP_REDIS_PORT', 'port'); # 端口 define( 'WP_REDIS_DATABASE', 1 ); # 数据库 define('WP_REDIS_PASSWORD', ['username', 'password']); # 用户名和密码
|
部分插件的配置
WP Super Cache
1 2
| define('WP_CACHE', true); define( 'WPCACHEHOME', '/you site directory/wp-content/plugins/wp-super-cache/' );
|
.htaccess
1 2 3 4
| php_value upload_max_filesize 200M php_value post_max_size 200M php_value max_execution_time 300 php_value max_input_time 300
|
修改 WordPress 上传文件大小限制