Gogs
官方网站mysql
Gogs
官网使用手册linux
git
用户若是以前已经建立能够跳过此步骤git
Gogs
推荐以git
用户运行github
sudo adduser git
web
将下载到的附件解压到自定义的目录,我这儿以/data/gogs/
目录为基准目录sql
$ 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
用户建立gogs
用户并赋予其gogs
数据库的所有权限vim
$ 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
服务,出现一下信息即启动服务成功。windows
建议切换到
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
的安装页面
仅以应用基本设置为例做详细说明
可选配置邮件服务设置
,服务器和其它服务设置
,管理员账号设置
可根据本身需求配置,后期也可经过配置文件来自定义修改。
建立管理员账号并非必须的,由于 ID=1 的用户将自动得到管理员权限。
配置文件位置:custom/conf/app.ini
[mailer] ENABLED = true # 启用邮件服务 HOST = smtp.exmail.qq.com:465 # SMTP信息,可从服务商获取 FROM = xxx@xxx.com # 发件人邮箱地址 USER = xxx@xxx.com # 邮箱的登陆用户名 PASSWD = xxxxxx # 邮箱的登陆密码
详细配置文件参考官方配置手册
在scripts/
文件夹下有关于多个系统的服务脚本:
$ ls autoboot.sh build_freebsd.sh build_linux64.sh build.sh init launchd mysql.sql README supervisor systemd windows
其中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
文章转载自个人博客:
Heier Blog:Heier Home