# 基于 golang 的开源论坛 bbs-go 的搭建步骤
本文总结了基于 golang 开发的开源论坛 bbs-go 的搭建步骤。
# 1. 下载代码
git clone https://github.com/mlogclub/mlog.git
# 2. 初始化数据库
# 2.1 创建数据库
create database bbsgo default CHARSET utf8mb4 collate utf8mb4_unicode_ci;
# 2.2 初始化数据
-- 初始化用户表
CREATE TABLE IF NOT EXISTS `t_user` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`username` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL,
`email` varchar(128) COLLATE utf8_unicode_ci DEFAULT NULL,
`nickname` varchar(16) COLLATE utf8_unicode_ci DEFAULT NULL,
`avatar` text COLLATE utf8_unicode_ci,
`password` varchar(512) COLLATE utf8_unicode_ci DEFAULT NULL,
`status` int(11) NOT NULL,
`roles` text COLLATE utf8_unicode_ci,
`type` int(11) NOT NULL,
`description` text COLLATE utf8_unicode_ci,
`create_time` bigint(20) DEFAULT NULL,
`update_time` bigint(20) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `username` (`username`),
UNIQUE KEY `email` (`email`),
KEY `idx_status` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- 初始化用户数据(用户名:admin、密码:123456)
INSERT INTO `t_user`(`id`, `username`, `nickname`, `avatar`, `email`, `password`, `status`, `create_time`, `update_time`, `roles`, `type`, `description`) VALUES (1, 'admin', '管理员', '', '', '$2a$10$ofA39bAFMpYpIX/Xiz7jtOMH9JnPvYfPRlzHXqAtLPFpbE/cLdjmS', 0, 1555419028975, 1555419028975, 'owner', 0, '轻轻地我走了,正如我轻轻的来。');
-- 初始化系统配置表
CREATE TABLE IF NOT EXISTS `t_sys_config` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`key` varchar(128) COLLATE utf8_unicode_ci NOT NULL,
`value` text COLLATE utf8_unicode_ci,
`name` varchar(32) COLLATE utf8_unicode_ci NOT NULL,
`description` varchar(128) COLLATE utf8_unicode_ci DEFAULT NULL,
`create_time` bigint(20) NOT NULL,
`update_time` bigint(20) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `key` (`key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- 初始化系统配置数据
insert into t_sys_config(`key`, `value`, `name`, `description`, `create_time`, `update_time`) values
('siteTitle', 'bbs-go', '站点标题', '站点标题', 1555419028975, 1555419028975),
('siteDescription', 'bbs-go,基于Go语言的开源社区系统', '站点描述', '站点描述', 1555419028975, 1555419028975),
('siteKeywords', 'bbs-go', '站点关键字', '站点关键字', 1555419028975, 1555419028975),
('siteNavs', '[{"title":"首页","url":"/"},{"title":"话题","url":"/topics"},{"title":"文章","url":"/articles"}]', '站点导航', '站点导航', 1555419028975, 1555419028975);
# 3. 运行后台服务
后台服务所在目录为 mblog/server/
后台基于 golang 开发, 注意配置本地的 golang 环境为 1.15 版本,该项目不支持低版本。
创建配置文件./server/bbs-go.yaml
Env: prod # 环境,线上环境:prod、测试环境:dev
BaseUrl: http://localhost:8082 # 网站域名
Port: 8082 # 端口
LogFile: /data/log/bbs-go/bbs-go.log # 日志文件
ShowSql: false # 是否打印sql
StaticPath: /data/www # 根路径下的静态文件目录,可配置绝对路径
# 数据库连接
MySqlUrl: root:123456@tcp(localhost:3306)/bbsgo?charset=utf8mb4&parseTime=True&loc=Local
# github登录配置
Github:
ClientID:
ClientSecret:
# qq登录配置
QQConnect:
AppId:
AppKey:
# 上传配置
Uploader:
# 启用上传方式, "aliyun或oss"表示使用Aliyun Oss, 否则使用本地存储
Enable: local
# 阿里云oss配置
AliyunOss:
Host: 请配置成你自己的
Bucket: 请配置成你自己的
Endpoint: 请配置成你自己的
AccessId: 请配置成你自己的
AccessSecret: 请配置成你自己的
StyleSplitter: 阿里云oss图片样式分隔符
StyleAvatar: 头像图片样式名称
StylePreview: 预览图片样式名称
StyleSmall: 小图样式名称
StyleDetail: 详情图片样式名称
# 本地文件上传
Local:
Host: http://localhost:8089/ # 上传文件域名
Path: /data/workspace/github/go/private/mlog/data # 上传目录
# 邮件服务器配置,用于邮件通知
Smtp:
Addr: smtp.qq.com
Port: 25
Username: 请配置成你自己的
Password: 请配置成你自己的
SSL: true
# 百度ai配置,用于自动分析文章摘要、标签
BaiduAi:
ApiKey:
SecretKey:
# 百度SEO相关配置
# 文档:https://ziyuan.baidu.com/college/courseinfo?id=267&page=2#h2_article_title14
BaiduSEO:
Site:
Token:
- 文件存储可以选择 aliyun oss,也可以选择本地存储。不想花钱,当然要配置为本地存储了
注意: 如果选择本地存储,那么还需为本地存储的根目录配置一个静态服务
- 将如上配置文件的内容按实际环境改动即可。
进入./server 目录下,执行 go build 即可完成编译并生成可执行文件 bbs-go。
执行./bbs-go,运行后台服务, 端口 8082
# 4. 运行前端页面服务
后台服务所在目录为 mblog/site/
低版本的 node 会报错,建议安装高版本,如 v15.0.1
# 4.1 安装依赖包
进入目录./site 后,执行 npm install
# 4.2 运行
进入目录./site 后,执行 npm run dev
则启动前端服务,服务端口 3000
# 5. 验证
访问http://localhost:3000
效果如下
管理员账号: admin/123456
细节请前往官方文档
文章来源于互联网:
基于golang的开源论坛bbs-go的搭建步骤
Top 100 Searched Drugs. Some are medicines that help people when doctors prescribe.
https://clomidc.fun/ clomid pill
Best and news about drug. Drugs information sheet.
Learn about the side effects, dosages, and interactions. Read now.
zithromax buy online no prescription
Drugs information sheet. Get warning information here.
What side effects can this medication cause? п»їMedicament prescribing information.
https://zithromaxa.fun/ zithromax generic price
Comprehensive side effect and adverse reaction information. Learn about the side effects, dosages, and interactions.
Learn about the side effects, dosages, and interactions. earch our drug database.
https://tadalafil1st.online/# lowest price tadalafil
Get warning information here. Get here.
Get warning information here. Cautions.
canadian pharmacy for cialis for sale
Read here. Definitive journal of drugs and therapeutics.
Long-Term Effects. What side effects can this medication cause?
buy tadalafil from india
Everything what you want to know about pills. п»їMedicament prescribing information.