数据库配置分离

This commit is contained in:
WispX
2018-10-13 10:23:42 +08:00
parent 9cae79fcf8
commit c36065fb5b
4 changed files with 27 additions and 15 deletions
+1 -1
View File
@@ -44,7 +44,7 @@
Apache直接使用.htaccess即可
4. 访问首页,未安装自动跳转至安装页面,根据页面提示安装即可。
5. 安装完成以后请设置runtime目录0777权限,如果你使用本地存储,public 目录也需要设置为0777权限
5. 安装完成以后请设置runtime目录0755权限,如果你使用本地存储,public 目录也需要设置为0755权限
联系我
---
+3 -3
View File
@@ -65,8 +65,8 @@ class Install extends Controller
if (!$mysqli->multi_query($sqlFile)) {
throw new Exception('数据写入失败');
}
$dataBasePath = $configPath . 'database.php';
$dataBaseFile = file_get_contents($dataBasePath);
$dbPath = $configPath . 'db.php';
$dataBaseFile = file_get_contents($dbPath);
$dataBaseFile = str_replace([
'{hostname}',
'{database}',
@@ -81,7 +81,7 @@ class Install extends Controller
$hostport,
], $dataBaseFile);
file_put_contents($dataBasePath, $dataBaseFile);
file_put_contents($dbPath, $dataBaseFile);
} catch (Exception $e) {
return $this->error($e->getMessage());
+3 -11
View File
@@ -9,19 +9,9 @@
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
return [
$database = [
// 数据库类型
'type' => 'mysql',
// 服务器地址
'hostname' => '{hostname}',
// 数据库名
'database' => '{database}',
// 用户名
'username' => '{username}',
// 密码
'password' => '{password}',
// 端口
'hostport' => '{hostport}',
// 连接dsn
'dsn' => '',
// 数据库连接参数
@@ -61,3 +51,5 @@ return [
// 断线标识字符串
'break_match_str' => [],
];
return array_merge($database, require(\think\facade\Env::get('config_path') . 'db.php'));
+20
View File
@@ -0,0 +1,20 @@
<?php
/**
* User: Wisp X
* Date: 2018/10/13
* Time: 10:18
* Link: https://gitee.com/wispx
*/
return [
// 服务器地址
'hostname' => '{hostname}',
// 数据库名
'database' => '{database}',
// 用户名
'username' => '{username}',
// 密码
'password' => '{password}',
// 端口
'hostport' => '{hostport}',
];