官方地址
安装
新建git
用户
如果之前已经创建可以跳过此步骤
Gogs
推荐以git
用户运行
sudo adduser git
二进制包安装
将下载到的附件解压到自定义的目录,我这儿以/data/gogs/
目录为基准目录
- $ ls /data/gogs/
- gogs gogs-repositories
- $ pwd
- /data/gogs/gogs
- $ ls /data/gogs/gogs/
- custom data gogs LICENSE log public README.md README_ZH.md scripts templates
数据库配置
执行数据库sql
语句
Gogs
目录下的scripts/MysqL.sql
为使用MysqL
数据库时需要执行的sql
命令,执行MysqL -u root -p < scripts/MysqL.sql
(需要输入数据库密码)初始化数据库
创建数据库gogs
用户
- $ MysqL -u root -p
- > # (输入密码)
- > create user 'gogs'@'localhost' identified by '密码';
- > grant all privileges on gogs.* to 'gogs'@'localhost';
- > flush privileges;
- > exit;
运行Gogs
服务
进入gogs
的数据目录,只需要执行./gogs web
命令即可启动gogs
服务,出现一下信息即启动服务成功。
建议切换到
git
用户执行此命令su - git
- $ /data/gogs/gogs/gogs web
- 2016/12/11 16:50:42 [T] Custom path: /data/gogs/gogs/custom
- 2016/12/11 16:50:42 [T] Log path: /data/gogs/gogs/log
- 2016/12/11 16:50:42 [I] Heier Git Server 0.9.97.0901
- 2016/12/11 16:50:42 [I] Log Mode: File(Info)
- 2016/12/11 16:50:42 [I] Cache Service Enabled
- 2016/12/11 16:50:42 [I] Session Service Enabled
- 2016/12/11 16:50:42 [I] Mail Service Enabled
- 2016/12/11 16:50:42 [I] Notify Mail Service Enabled
- 2016/12/11 16:50:42 [I] Git Version: 2.11.0.22.g8d7a455
- 2016/12/11 16:50:42 [I] sqlite3 Supported
- 2016/12/11 16:50:42 [T] Doing: CheckRepoStats
- 2016/12/11 16:50:42 [I] Run Mode: Production
- 2016/12/11 16:50:42 [I] Listen: http://127.0.0.1:3000
使用浏览器访问http://服务器ip:3000
即可打开Gogs
的安装页面
配置
安装页面配置
仅以应用基本设置为例作详细说明
可选配置邮件服务设置
,服务器和其它服务设置
,管理员帐号设置
可根据自己需求配置,后期也可通过配置文件来自定义修改。
配置文件调整
配置文件位置:custom/conf/app.ini
配置Mailer
配置Linux服务
在scripts/
文件夹下有关于多个系统的服务脚本:
其中init
,systemd
以及windows
目录分别为linux、Windows下服务脚本。
在此仅以CentOS为例:
复制
scripts/init/centos/gogs
到/etc/init.d/
目录下:sudo cp scripts/init/centos/gogs /etc/init.d/
切换到
/etc/init.d/
目录为脚本赋予可执行权限sudo chmod +x gogs
更改
gogs
脚本内关于GOGS_HOME
目录位置的设置(这儿使用vim
编辑)GOGS_HOME=/data/gogs/gogs
使用服务管理命令管理服务
sudo service gogs start/stop/restart/status
配置
Gogs
开机自启动sudo chkconfig --add gogs