基础配置
# mysql数据库配置
位于`phalapi/.env`
主要配置以下内容:
- 数据库名:PHALAPI_DB_NAME
- 数据库用户名:PHALAPI_DB_USER
- 数据库密码:PHALAPI_DB_PASSWORD
示例:
```php
# 数据库配置
PHALAPI_DB_TYPE="mysql"
PHALAPI_DB_HOST="127.0.0.1"
PHALAPI_DB_NAME="cloud"
PHALAPI_DB_USER="cloud"
PHALAPI_DB_PASSWORD="C6jYYiHx *** LxYNp"
PHALAPI_DB_PORT="3306"
PHALAPI_DB_CHARSET="UTF8"
```
宝塔对应的信息:

>d 添加数据库后,务必到[计划任务]页面添加定时备份任务,以确保您的数据安全
# 跨域设置
位于`phalapi/config/app.php`
修改其中的whitelist为你网站的api接口域名
示例:
```php
/**
* 扩展类库 - CORS跨域扩展
* https://github.com/gongshunkai/phalapi-cors
*/
'cors' => array(
//域名白名单
'whitelist' => array(
'http://api.aidongyun.cn',
'http://manage.aidongyun.cn',
'http://cloud.aidongyun.cn',
),
//header头
'headers' => array(
'Access-Control-Allow-Methods' => 'GET, POST, PUT, DELETE, OPTIONS', //支持的请求类型
'Access-Control-Allow-Credentials' => 'true' //支持cookie
)
),
```
# api接口地址配置
**用户后台**的api接口设置,位于`phalapi/public/cloud/assets/module/setter.js`
**管理后台**的api接口设置,位于`phalapi/public/manage/assets/module/setter.js`
修改baseServer的值,为api接口域名
示例:
```javascript
layui.define(['table'], function (exports) {
var setter = {
baseServer: 'http://api.aidongyun.cn/', // 接口地址
......
};
});
```
>d 两处接口地址,都要修改
socket业务的接口域名设置,位于`GatewayWorker/Applications/YourApp/Events.php`
修改api接口域名
```
const API_HOST = 'http://api.aidongyun.cn/';
```
# socket服务地址配置
**用户后台**的socket接口设置,位于`phalapi/public/cloud/index.html`
**管理后台**的socket接口设置,位于`phalapi/public/manage/index.html`
修改接口地址:
```
var wsUrl = 'ws://' + 'api.aidongyun.cn' + ':8282';
```
>d 两处服务地址,都要修改
# 补充
还有一种简单替换接口地址的办法,就是批量搜索和替换。熟练此操作,可以省去逐个替换的时间
