gogs代码托管


安装

https://gogs.io/docs

// 克隆仓库到本地
git clone https://github.com/gogs/gogs.git
git clone --depth 1 https://github.com/gogs/gogs.git gogs
// 修改工作目录
cd gogs
// 编译主程序,这个步骤会下载所有的依赖
go build -o gogs

工作目录配置

// GO的安装目录,如:C:\Program Files\Go
Languages & Frameworks -> Go -> GOROOT

上线配置

Program arguments:web
Environment:CGO_ENABLED=0;GOOS=linux;GOARCH=amd64
go_build_gogs_io_gogs.exe web --port 1024

配置用户

useradd git
passwd git
chown -R git:git .
chmod +x gogs

配置数据库

mysql -u root -p
drop database gogs;
create database gogs default character set utf8mb4 collate utf8mb4_0900_ai_ci;

nginx配置

server {
    listen       80;
    server_name  127.0.0.1;

    location / {
        proxy_pass http://127.0.0.1:1024;
    }
}

后台运行

nohup ./go_build_gogs_io_gogs_linux web --port 1024 > /dev/null 2>&1 &

centos

git clone --depth 1 https://github.com/gogs/gogs.git gogs
export PATH=$PATH:/root/go/bin
export GOPATH=/root/gopath
cd gogs
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct
yum install gcc-c++
go build -o gogs
gogs web --port 123
wget https://studygolang.com/dl/golang/go1.17.linux-amd64.tar.gz
tar zxvf go1.17.linux-amd64.tar.gz -C /root

gogs/custom/conf

[repository.upload]
FILE_MAX_SIZE = 100