## 数据库配置
微擎系统支持数据库的主从配置(一主多从),只需要进行简单的配置即可。
| 变量 | 描述 |
| --- | --- |
| $config\[‘db’\]\[‘master’\]\[‘host’\] | 数据库主机地址 |
| $config\[‘db’\]\[‘master’\]\[‘username’\] | 数据库用户名 |
| $config\[‘db’\]\[‘master’\]\[‘password’\] | 数据库密码 |
| $config\[‘db’\]\[‘master’\]\[‘port’\] | 数据库端口 |
| $config\[‘db’\]\[‘master’\]\[‘database’\] | 数据库名 |
| $config\[‘db’\]\[‘master’\]\[‘charset’\] | 数据库编码 |
| $config\[‘db’\]\[‘master’\]\[‘pconnect’\] | 数据库连接类型 |
| $config\[‘db’\]\[‘master’\]\[‘tablepre’\] | 数据库表前缀 |
| $config\[‘db’\]\[‘slave\_status’\] | 读写分离开关 |
| $config\[‘db’\]\[‘slave’\]\[‘1’\] | 只读实例配置项,1为只读实例编码,多台实例可新增\[2\],\[3\],\[4\] |
| $config\[‘db’\]\[‘common’\]\[‘slave\_except\_table’\] | 不进行主从分离的表 |
配置主从支持在系统 “data/config.php” 文件中,部分用户没有master项,`$config['db']['host']`等同于`$config['db']['master']['host']`,具体配置如下:
### 示例:
~~~
//主库配置
$config['db']['master']['host'] = '192.168.1.2';
$config['db']['master']['username'] = 'root';
$config['db']['master']['password'] = '123456';
$config['db']['master']['port'] = '3306';
$config['db']['master']['database'] = 'we7_pro';
$config['db']['master']['charset'] = 'utf8';
$config['db']['master']['pconnect'] = 0;
$config['db']['master']['tablepre'] = 'ims_';
//以下选项,如果没有请自行添加
//从库配置
$config['db']['slave_status'] = false; //是否开启主从配置
$config['db']['slave']['1']['host'] = '192.168.1.3'; //从库配置要与主库相同
$config['db']['slave']['1']['username'] = 'root';
$config['db']['slave']['1']['password'] = '123456';
$config['db']['slave']['1']['port'] = '3306';
$config['db']['slave']['1']['database'] = 'we7_pro';
$config['db']['slave']['1']['charset'] = 'utf8';
$config['db']['slave']['1']['pconnect'] = 0;
$config['db']['slave']['1']['tablepre'] = 'ims_';
$config['db']['slave']['1']['weight'] = 0; //从库的权重值,默认0即可
//不进行主从分离的表
$config['db']['common']['slave_except_table'] = array(
'core_sessions',
);
~~~
## 系统COOKIE配置项
| 变量 | 描述 |
| --- | --- |
| $config\[‘cookie’\]\[‘pre’\] | cookie前缀,无需更改,系统随机生成 |
| $config\[‘cookie’\]\[‘domain’\] | cookie作用域 |
| $config\[‘cookie’\]\[‘path’\] | cookie作用目录,无需更改 |
## 系统设置
| 变量 | 描述 |
| --- | --- |
| $config\[‘setting’\]\[‘charset’\] | 系统编码 |
| $config\[‘setting’\]\[‘cache’\] | 缓存类型, 默认为mysql, 支持memcache,redis |
| $config\[‘setting’\]\[‘timezone’\] | 时区 |
| $config\[‘setting’\]\[‘memory\_limit’\] | 内存大小 |
| $config\[‘setting’\]\[‘filemode’\] | 文件权限 |
| $config\[‘setting’\]\[‘authkey’\] | 数据加密key |
| $config\[‘setting’\]\[‘founder’\] | 创始人设置 |
| $config\[‘setting’\]\[‘development’\] | 调试模式(开发模式)开关,开发者常用 |
| $config\[‘setting’\]\[‘referrer’\] | 无 |
## Memcache 缓存设置
| 变量 | 描述 |
| --- | --- |
| $config\[‘setting’\]\[‘memcache’\]\[‘server’\] | memcache服务地址 |
| $config\[‘setting’\]\[‘memcache’\]\[‘port’\] | 端口 |
| $config\[‘setting’\]\[‘memcache’\]\[‘pconnect’\] | 连接类型 |
| $config\[‘setting’\]\[‘memcache’\]\[‘timeout’\] | 超时时间 |
| $config\[‘setting’\]\[‘memcache’\]\[‘session’\] | 是否缓存session |
## Redis 缓存设置
| 变量 | 描述 |
| --- | --- |
| $config\[‘setting’\]\[‘redis’\]\[‘server’\] | redis服务地址 |
| $config\[‘setting’\]\[‘redis’\]\[‘port’\] | 端口 |
| $config\[‘setting’\]\[‘redis’\]\[‘pconnect’\] | 连接类型 |
| $config\[‘setting’\]\[‘redis’\]\[‘timeout’\] | 超时时间 |
| $config\[‘setting’\]\[‘redis’\]\[‘session’\] | 是否缓存session |
## 请求代理设置
在负载均衡的环境中,后端服务器可以通过前端服务代理来请求外网的URL
| 变量 | 描述 |
| --- | --- |
| $config\[‘setting’\]\[‘proxy’\]\[‘host’\] | 代理主机信息 |
| $config\[‘setting’\]\[‘proxy’\]\[‘auth’\] | 代理验证信息 |
## 上传配置 (已废弃,统一在系统附件设置中更改)
| 变量 | 描述 |
| --- | --- |
| $config\[‘upload’\]\[‘image’\]\[‘extentions’\] | 上传图片的类型 |
| $config\[‘upload’\]\[‘image’\]\[‘limit’\] | 上传图片的大小 |
| $config\[‘upload’\]\[‘attachdir’\] | 上传目录 |
| $config\[‘upload’\]\[‘audio’\]\[‘extentions’\] | 上传音频的类型 |
| $config\[‘upload’\]\[‘audio’\]\[‘limit’\] | 上传音频的大小 |