# de-news-admin-server **Repository Path**: byte-and-deepcode/de-news-admin-server ## Basic Information - **Project Name**: de-news-admin-server - **Description**: 后台后端仓库 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-12-29 - **Last Updated**: 2021-12-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # dc-news-admin-api 字节跳动训练营项目后台管理系统后端 **注意:这个模块的功能未完成** ## 技术栈 - Gin - Gorm - jwt-go - MySQL - Zap ## 环境 - Go v1.16+ - Mysql 8.0+ ## API文档 [https://docs.apipost.cn/preview/468b7d7c0f464469/336e2e3e0236e76c](https://docs.apipost.cn/preview/468b7d7c0f464469/336e2e3e0236e76c) ## 本地运行(Windows) ### 安装Golang环境 你已经是个成年人了,自行百度吧 ### 设置国内源 ``` go env -w GOPROXY=https://goproxy.cn,direct ``` ### clone仓库 ``` git clone https://gitee.com/kakkk/dc-news-admin-api cd dc-news-admin-api ``` ### 编译 ``` go mod tidy go build ``` ### 修改配置文件 在`./conf/`目录新建`config.ini`配置文件: ``` port = 8080 #后端服务端口 release = false #是否为release模式 api_domain = http://localhost:8080 #后端api域名和端口 [mysql] user = root #数据库用户 password = root #数据库密码 host = 127.0.0.1 #数据库地址 port = 3306 #数据库端口 db = dc_news #数据库名 ``` ### 运行 ``` ./dc-news-admin-api.exe ``` ## 部署(Ubuntu 20.04) ### 安装Golang环境 ``` sudo add-apt-repository ppa:longsleep/golang-backports sudo apt update sudo apt install golang-go ``` ### 设置国内源 ``` go env -w GOPROXY=https://goproxy.cn,direct ``` ### clone仓库 ``` git clone https://gitee.com/byte-and-deepcode/de-news-server.git cd dc-news ``` ### 编译 ``` go mod tidy go build ``` ### 修改配置文件 在`./conf/`目录新建`config.ini`配置文件: ``` port = 8080 #后端服务端口 release = false #是否为release模式 api_domain = http://localhost:8080 #后端api域名和端口 [mysql] user = root #数据库用户 password = root #数据库密码 host = 127.0.0.1 #数据库地址 port = 3306 #数据库端口 db = dc_news #数据库名 ``` 修改配置文件并保存 ### 后台运行 ``` nohup ./dc-news-admin-api & ``` ### 结束运行 查看进程ID ``` ps -aux | grep dc-news-admin-api ``` 根据进程ID结束运行 ``` kill 进程ID ``` ### Nginx反向代理 ``` location / { proxy_pass http://localhost:8080; proxy_set_header Host localhost; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header REMOTE-HOST $remote_addr; add_header X-Cache $upstream_cache_status; #Set Nginx Cache add_header Cache-Control no-cache; } ``` ### 日志目录 ``` ./logs/dc-news-admin-api.log ```