macOS gogs 安装

gogs官网

需求

个人代码仓库,文档仓库(macdown 文件)

为什么使用gogs

  • 对比gitlab
维度 gitlab gogs
Mac支持 Mac上安装失败 Go语言写的,兼容各个系统
依赖 Nginx 、postgresql、redis 等等 git, 数据库可以用sqlite
资源占用 Gitlab 配置要求CPU两核,内存4G以上 x

因为是个人使用,相比gitlab gogs 更轻,更易配置

安装过程

下载安装

  • 安装git
  • 下载二进制包 安装包github链接

配置启动

  • 先说明一下我的安装目录
//主目录, 我在共享目录下新建了个App文件夹, 用来放一些app 还有 app 的数据
/Users/vector/App/gogs

//应用目录
/Users/vector/App/gogs/bin  

//应用数据
/Users/vector/App/gogs/data  


//这里效仿apple sandbox, 在data目录下新建了2个文件夹 Documents、Library

// Gogs应用数据库
/Users/vector/App/gogs/data/Documents 

//Gogs应用数据
/Users/vector/App/gogs/data/Gogs/Library  

  • gogs 配置文件

在gogs 可执行文件(/Users/vector/App/gogs/bin/gogs )同级目录(/Users/vector/App/gogs/bin/) 下新建文件夹 custom(/Users/vector/App/gogs/bin/custom), 新建目录 conf, 创建 app.ini 文件(/Users/vector/App/gogs/bin/custom/conf/app.ini), 编辑 app.ini (完整实例)

; App name that shows on every page title
APP_NAME = GitServer
; The name of the system user that runs Gogs
RUN_USER = vector
; Either "dev", "prod" or "test"
RUN_MODE = prod

[server]
; HTTP support
PROTOCOL         = http
DOMAIN           = code.xxx.com
ROOT_URL         = http://code.xxx.com:7880/
HTTP_ADDR        = 192.168.11.2
HTTP_PORT        = 7880
; SSH support
DISABLE_SSH      = false
SSH_DOMAIN       = code.xxx.com
SSH_PORT         = 7822
START_SSH_SERVER = true
SSH_ROOT_PATH    = /User/vector/.ssh
OFFLINE_MODE     = false
REWRITE_AUTHORIZED_KEYS_AT_START = false

[repository]
ROOT = /Users/vector/App/gogs/data/Library

[database]
; Either "mysql", "postgres" or "sqlite3", you can connect to TiDB with MySQL protocol
DB_TYPE  = sqlite3
PATH     = /Users/vector/App/gogs/data/Documents/gogs.db

[log]
MODE      = file
LEVEL     = Info
ROOT_PATH = /Users/vector/App/gogs/bin/log

ROOT_URL 是我本地的域名,由于我本地搭建了dns服务器, 所以这里用的域名

  • 运行
/Users/vector/App/gogs/bin/gogs web

2018/12/31 02:23:41 [TRACE] Custom path: /Users/vector/App/gogs/bin/custom
2018/12/31 02:23:41 [TRACE] Log path: /Users/vector/App/gogs/bin/log
2018/12/31 02:23:41 [TRACE] Build Time: 2018-06-06 01:47:22 UTC
2018/12/31 02:23:41 [TRACE] Build Git Hash: 91441c3fb29d8ead645d8fffa4658d749d5b3fc3
2018/12/31 02:23:41 [TRACE] Log Mode: File (Trace)
2018/12/31 02:23:41 [ INFO] GitServer 0.11.53.0603
  • 配置开机自启动

创建 /Users/vector/Library/LaunchAgents/gogs.plist 文件





    ProgramArguments
    
        /Users/vector/App/gogs/bin/gogs
        web
    
    SoftResourceLimits
    
        NumberOfFiles
        65536
    
    StandardErrorPath
    /Users/vector/App/gogs/bin/log/stderr.log
    StandardOutPath
    /Users/vector/App/gogs/bin/log/stdout.log
    WorkingDirectory
    /Users/vector/App/gogs/
    UserName
    vector
    RunAtLoad
    
    KeepAlive
    
    Label
    io.gogs.web


加载

launchctl load /Users/vector/Library/LaunchAgents/gogs.plist

问题

  • 当时最新版本为0.11.66 发现不支持sqlite, 应该是gogs的一个bug, 后来选择旧版本 0.11.53就ok了
  • sourcetree 账户选项中没有gogs 选项, 改用ssh就ok了

mac 折腾系列

你可能感兴趣的:(macOS gogs 安装)