数据库配置分离
This commit is contained in:
@@ -44,7 +44,7 @@
|
||||
Apache直接使用.htaccess即可
|
||||
|
||||
4. 访问首页,未安装自动跳转至安装页面,根据页面提示安装即可。
|
||||
5. 安装完成以后请设置runtime目录0777权限,如果你使用本地存储,public 目录也需要设置为0777权限
|
||||
5. 安装完成以后请设置runtime目录0755权限,如果你使用本地存储,public 目录也需要设置为0755权限
|
||||
|
||||
联系我
|
||||
---
|
||||
|
||||
@@ -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
@@ -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'));
|
||||
@@ -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}',
|
||||
];
|
||||
Reference in New Issue
Block a user