Debian安装Gogs( Git 服务)

概述

Gogs 的目标是打造一个最简单、最快速和最轻松的方式搭建自助 Git 服务。使用 Go 语言开发使得 Gogs 能够通过独立的二进制分发,并且支持 Go 语言支持的 所有平台,包括 Linux、Mac OS X、Windows 以及 ARM 平台。

Gogs 项目代码 100% 开源并可无条件免费使用。所有的源代码均通过 MIT 授权协议 托管在 GitHub 上。

Gogs要求配置低,不像Gitlab动辄需要4G内存才能稳定运行,一个廉价的树莓派的配置足以满足 Gogs 的最低系统硬件要求。

官网:https://gogs.io

安装数据库

数据库可以选用MySQL、PostgreSQL、MSSQL 、TiDB以及SQLite等。

这里选用Postgresql,参照笔记《Debian安装Postgresql数据库》安装。

安装Git

apt-get install git

添加git用户

sudo useradd git

创建git用户工作目录

mkdir -p /home/git

sudo chown -R git:git /home/git

安装Gogs

1.下载Gogs的二进制安装包

在网页https://gogs.io/docs/installation中,获取最新的zip路径。下载,解压缩至git用户目录下。

2.更改Gogs文件的权限及所有者

进入解压缩后的Gogs的文件夹:cd /home/git/gogs

sudo chmod -R 700 gogs

sudo chown -R git:git gogs

3.创建配置文件

mkdir -p custom/conf

vim custom/conf/app.ini

参照官网的《配置文件手册》,编写基本配置文件。

[database]
DB_TYPE = postgres
USER = postgres 
PASSWD = postgres

[security]
INSTALL_LOCK = true

4.使用git用户运行Gogs

前台运行:

su - git -c "cd /home/git/gogs && ./gogs web"

后台运行:

su - git -c "cd /home/git/gogs && ./gogs web &"

没有错误的话,就可以按照提示,通过浏览器访问安装网页了,例如:http://192.168.50.150:3000

安装提示进行安装即可,在安装界面创建的用户即为Gogs的超级管理员。

5.添加服务启动项

ln -sf /home/git/gogs/scripts/systemd/gogs.service /etc/systemd/system/
chmod u+x /home/git/gogs/scripts/systemd/gogs.service
ln -sf /home/git/gogs/scripts/init/centos/gogs /etc/init.d/
chmod u+x /home/git/gogs/scripts/init/centos/gogs
systemctl enable gogs
systemctl start gogs

留下评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注