前言

GitHub已经成为首选的代码托管平台,因为它又很多很棒的功能,操作简单,几乎所有的开发者都喜欢它。但是搭建GitLab过程并没有想象中的简单,利用Bitnami当然也是一种偷懒的好选择。Gogs (Go Git Service) 是一款极易搭建的自助 Git 服务,Gogs 的目标是打造一个最简单、最快速和最轻松的方式搭建自助 Git 服务。使用 Go 语言开发使得 Gogs 能够通过独立的二进制分发,并且支持 Go 语言支持的 所有平台,包括 Linux、Mac OS X、Windows 以及 ARM 平台。

Gogs可能是比GitLab更好的选择

更新记录

Bitnami GitLab Stack

Bitnami GitLab Stack ships with the following software versions

  • GitLab 8.5.7
  • Apache 2.4.18
  • ImageMagick 6.7.5
  • PostgreSQL 9.4.6
  • Git 2.7.4
  • Ruby 2.1.8
  • Rails 4.2.5.1
  • RubyGems 1.8.12

Btinami GitLab Stack 安装真心简单,爽
chmod 755 bitnami-gitlab-8.5.7-0-linux.run

Gogs功能特性

  • 支持活动时间线
  • 支持 SSH 以及 HTTP/HTTPS 协议
  • 支持 SMTP、LDAP 和反向代理的用户认证
  • 支持反向代理子路径
  • 支持用户、组织和仓库管理系统
  • 支持仓库和组织级别 Web 钩子(包括 Slack 集成)
  • 支持仓库 Git 钩子和部署密钥
  • 支持仓库工单(Issue)、合并请求(Pull Request)和 Wiki
  • 支持添加和删除仓库协作者
  • 支持 Gravatar 以及自定义源
  • 支持邮件服务
  • 支持后台管理面板
  • 支持 MySQL、PostgreSQL、SQLite3 和 TiDB(实验性支持) 数据库
  • 支持多语言本地化(15 种语言)

以GitHub作为参考比较对象

特性

Gogs

Gitlab

Github

Dashboard & File Browser

Y

Y

Y

Issue Tracking, Milestones & Commit keywords

Y

Y

Y

Organizations support

N

Y

Y

Wiki

N

Y

Y

Code Review

N

Y

Y

Code Snippets

N

Y

Y

Web Hooks

Y

Y

Y

Git Hooks

Y

* Enterprise

* Enterprise

LDAP Login

Y

Y

Y

LDAP Group Sync

N

* Enterprise

* Enterprise

Branded Login Page

N

* Enterprise

* Enterprise

Language

Go

Ruby

Ruby

Platform

Cross-Platform

Linux

* Virtual Machine

License

MIT

MIT

Proprietary

Resource Usage

Low

Medium/High

Medium/High

Gogs环境要求

我以rhel6.3为例,已经属于生命周期边缘了

#安装git
yum install -y git
git --version
git version 1.7.1

#安装mysql-server
yum install -y mysql-server
mysql --version
mysql Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86_64) using readline 5.1

#启动数据库
service mysqld start
chkconfig mysqld on

#创建gogs数据库
cd /home/git/gogs/scripts
#mysql -u root -p < mysql.sql
mysql -u root -p
# (输入密码,无密码直接跳过)
set global storage_engine = 'InnoDB';
create database gogs character set utf8 collate utf8_bin;
create user 'gogs'@'localhost' identified by 'gogs';
grant all privileges on gogs.* to 'gogs'@'localhost';
flush privileges;
exit;


部署Gogs

Gogs是一款极易搭建的自助Git服务

#创建git用户
sudo adduser git
su - git

#解压gogs
cd /home/git
unzip gogs_v0.9.13_linux_amd64.zip
ls /home/git/gogs/
gogs LICENSE public README.md README_ZH.md scripts templates

#启动gogs
cd /home/git/gogs
./gogs web
2016/03/31 16:23:53 [W] Custom config '/home/git/gogs/custom/conf/app.ini' not found, ignore this if you're running first time
2016/03/31 16:23:53 [T] Custom path: /home/git/gogs/custom
2016/03/31 16:23:53 [T] Log path: /home/git/gogs/log
2016/03/31 16:23:53 [I] Gogs: Go Git Service 0.9.13.0318
2016/03/31 16:23:53 [I] Log Mode: Console(Trace)
2016/03/31 16:23:53 [I] Cache Service Enabled
2016/03/31 16:23:53 [I] Session Service Enabled
2016/03/31 16:23:53 [I] SQLite3 Supported
2016/03/31 16:23:53 [I] Run Mode: Development
2016/03/31 16:23:54 [I] Listen: http://0.0.0.0:3000

#后台运行
nohup ./gogs web &
tail -f nohup.out


app.ini配置文件

注意DOMAIN和ROOT_URL这两个参数

#首次安装可以打开浏览器完成剩余配置
http://ip:3000/install

#通过修改app.ini也可以
vi /home/git/gogs/custom/conf/app.ini

APP_NAME = Gogs: Go Git Service
RUN_USER = git
RUN_MODE = prod

[database]
DB_TYPE = mysql
HOST = 127.0.0.1:3306
NAME = gogs
USER = gogs
PASSWD = gogs
SSL_MODE = disable
PATH = data/gogs.db

[repository]
ROOT = /home/git/gogs-repositories

[server]
DOMAIN = 172.28.70.134
HTTP_PORT = 3000
ROOT_URL = http://172.28.70.134:3000/
DISABLE_SSH = false
SSH_PORT = 22
OFFLINE_MODE = false

[mailer]
ENABLED = false

[service]
REGISTER_EMAIL_CONFIRM = false
ENABLE_NOTIFY_MAIL = false
DISABLE_REGISTRATION = false
ENABLE_CAPTCHA = true
REQUIRE_SIGNIN_VIEW = false

[picture]
DISABLE_GRAVATAR = false

[session]
PROVIDER = file

[log]
MODE = file
LEVEL = Info
ROOT_PATH = /home/git/gogs/log

[security]
INSTALL_LOCK = true
SECRET_KEY = i4B7R55aRaFdw8j