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服务
https://gogs.io/docs

#创建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这两个参数
https://gogs.io/docs/advanced/configuration_cheat_sheet...

#首次安装可以打开浏览器完成剩余配置
<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