1 Star 15 Fork 6

Lucky.麒麟 / golang-blog

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

golang-blog博客网站

项目介绍

基于golang+React的博客网站,支持常规的博客文章管理的功能,并包含一些有意思的功能:代码库、图库,文件库等等。

首页大体如下:

软件架构

整体使用前后端分离开发

  • 服务端:gin、xorm、jwt、logrus
  • web端:react、antd、react-redux、react-router、axios

现阶段项目还在开发中,如有使用其他的框架,在添加!

模块介绍

前端已经完成页面:

文章详情:

文章归档:

后端已完成的页面:

登录页面:

文章分类管理:

文章管理:

其他模块正在开发,敬请期待......

安装教程

服务段:

先编译go文件:

CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build main.go   # mac的编译
========================================================================
set GOARCH=amd64
set GOOS=linux
go build   # win的编译

接着我们可以将blog-server/config/config.yml文件复制一份修改:

# 数据库配置
mysql:
  category: mysql
  prefix: blog_   
  database: blog_db_new   # 修改你自己的数据库名,ip和端口账号密码
  ip: 127.0.0.1      
  part: 3306
  username: root
  password: 123456
  print: true
  max-idle-conns: 10
  max-open-conns: 100
# 服务器端口
system:
  part: :9091
  stauts: debug
logger:
  path: /home/blog_server/logs
  name: memory_box.log
# jwt配置
jwt:
  sign-key: 123456
  expires-time: 3000
  issuer: molong
# 验证码
captcha:
  key-long: 6
  img-width: 240
  img-height: 60
file:
  basePath: /home/blog_server/files

接这样config.yamlgo build之后的二进制文件复制到云服务器上

需要创建fileslogs文件夹。启动脚本如下(需要给脚本添加执行权限):

nohup ./blog_server --config=config.yml > run.out 2>&1 &
前端:

修改blog_web/src/api/http.js文件中的服务端接口路径:

axios.defaults.baseURL = process.env.NODE_ENV === 'production' ? 'http://云服务器IP地址:8080/api' : 'http://localhost:9091/api';

点击package.json中的build命令:

接着将build文件夹下的文件全部复制到云服务器的指定文件夹下。

nginx配置
server {
        listen       80;
        server_name  localhost;

        gzip on;

        location / {
                root /opt/nginx/html/blog/;  # 你放置打包文件的目录
                index index.html;
                try_files $uri $uri/ @router;
                index index.html;
        }
        location @router {
                rewrite ^.*$ /index.html last;
        }

        location /api {
                proxy_pass       http://IP:8080/api;
        }
}

配置好之后重新加载配置文件就可以。

参与贡献

  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request

特技

  1. 使用 Readme_XXX.md 来支持不同的语言,例如 Readme_en.md, Readme_zh.md
  2. Gitee 官方博客 blog.gitee.com
  3. 你可以 https://gitee.com/explore 这个地址来了解 Gitee 上的优秀开源项目
  4. GVP 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
  5. Gitee 官方提供的使用手册 https://gitee.com/help
  6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 https://gitee.com/gitee-stars/
MIT License Copyright (c) 2021 墨龙 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

基于golang+React的博客网站 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Go
1
https://gitee.com/molonglove/golang-blog.git
git@gitee.com:molonglove/golang-blog.git
molonglove
golang-blog
golang-blog
master

搜索帮助