'sqlite',
'sqlite_path' => $sqlite_path,
'host' => '',
'port' => '',
'db_name' => '',
'username' => '',
'password' => ''
];
} else {
$config = [
'type' => 'mysql',
'host' => $_POST['db_host'],
'port' => $_POST['db_port'],
'db_name' => $_POST['db_name'],
'username' => $_POST['db_user'],
'password' => $_POST['db_pass'],
'sqlite_path' => ''
];
}
require_once __DIR__ . '/config/database.php';
try {
file_put_contents(__DIR__ . '/config/db_config.php', "getConnection();
$message = '数据库连接成功!';
$message_type = 'success';
header('Location: install.php?step=3');
exit;
} catch (Exception $e) {
if (file_exists(__DIR__ . '/config/db_config.php')) {
unlink(__DIR__ . '/config/db_config.php');
}
$message = $e->getMessage();
$message_type = 'error';
}
} elseif ($step == 3) {
// 初始化数据库表结构(略,可复用你原有的表结构SQL)
// ...
file_put_contents(__DIR__ . '/install.lock', 'installed');
header('Location: install.php?step=4');
exit;
}
}
// 环境检查
function checkEnvironment() {
$checks = [
'PHP版本 >= 7.4' => version_compare(PHP_VERSION, '7.4.0', '>='),
'PDO扩展' => extension_loaded('pdo'),
'PDO MySQL扩展' => extension_loaded('pdo_mysql'),
'PDO SQLite扩展' => extension_loaded('pdo_sqlite'),
'GD扩展' => extension_loaded('gd'),
'cURL扩展' => extension_loaded('curl'),
'config目录可写' => is_writable(__DIR__ . '/config'),
'data目录可写' => is_writable(__DIR__ . '/data') || mkdir(__DIR__ . '/data', 0755, true)
];
return $checks;
}
$env_checks = checkEnvironment();
?>
安装向导 - 内容投稿系统
环境检查
正在检查服务器环境是否满足运行要求...
环境检查未通过,请先解决上述问题后再继续安装。
数据库配置
请选择数据库类型并配置连接信息。
初始化数据库
数据库连接成功!现在将创建必要的数据表。
安装完成
恭喜!内容投稿系统安装成功!
安全提醒
为了系统安全,请立即删除或重命名 install.php 文件!
默认管理员账户
用户名:admin
密码:admin
⚠️ 请登录后台后立即修改默认密码!
下一步操作
- 删除或重命名 install.php 文件以确保安全
- 配置Web服务器(如Apache、Nginx)
- 设置适当的文件权限
- 登录管理后台修改默认密码