gogs git 服务器极速搭建

背景

小型团队合作中,需要代码托管在内网,gitlab 等搭建比较复杂,经过一番搜寻发现gogs满足需求

  • 基本用户管理
  • 后台管理面板,能在web端查看管理
  • 安装配置极简

安装配置

gogs是支持多个平台,这里我们选择ubuntu

1.下载git和gogs安装包

sudo apt install wget git
wget "https://ghproxy.com/github.com/gogs/gogs/releases/download/v0.13.0/gogs_0.13.0_linux_amd64.tar.gz"
tar xzf gogs_0.13.0_linux_amd64.tar.gz

目录随意,这里我解压到HOME目录
gogs git 服务器极速搭建_第1张图片

2. 初始化服务

项目不大,数据库选择内置的Sqlite3就行,减少额外步骤安装配置数据库等
执行./gogs web然后浏览器访问http://localhost:3000配置即可

gogs git 服务器极速搭建_第2张图片

如图:

  • 数据库选择sqlite3
  • 用户和网址选择当前用户以及服务器IP地址
  • 设置一个管理员账号、邮箱、密码等
    点立即安装即可完成

gogs git 服务器极速搭建_第3张图片

3. 安装为开机服务脚本[可选]

默认每次执行gogs web即可开启服务正常使用,如果想做成开机启动脚本,修改scripts/systemd/gogs.service,并创建一个服务
这里用户名和目录后内容如下:

[Unit]
Description=Gogs
After=syslog.target
After=network.target
After=mariadb.service mysql.service mysqld.service postgresql.service memcached.service redis.service

[Service]
Type=simple
User=leo
Group=leo
WorkingDirectory=/home/leo/gogs
ExecStart=/home/leo/gogs/gogs web
Restart=always
Environment=USER=leo HOME=/home/leo

# Some distributions may not support these hardening directives. If you cannot start the service due
# to an unknown option, comment out the ones not supported by your version of systemd.
ProtectSystem=full
PrivateDevices=yes
PrivateTmp=yes
NoNewPrivileges=true

[Install]
WantedBy=multi-user.target

安装service

sudo mv -v gogs.service /usr/lib/systemd/system/
sudo systemctl enable gogs.service && sudo systemctl start gogs.service

使用演示

访问http://localhost:3000使用步骤2中的账号密码登录创建一个仓库

gogs git 服务器极速搭建_第4张图片

克隆仓库提交并查看

gogs git 服务器极速搭建_第5张图片

查看仓库

gogs git 服务器极速搭建_第6张图片

更多功能需要参考官网或自行摸索, 如:

  • 用户管理
  • 权限配置
  • wiki文档
  • 提交合并等。。

gogs git 服务器极速搭建_第7张图片

你可能感兴趣的:(git,服务器,运维)