Gogs 安装和配置

1.先查看Git版本

git --version

2.创建一个git用户组

groupadd git

3.创建一个git用户并添加到git用户组

useradd -g git git

4.修改git用户的密码

passwd git

5.修改好了之后, 切换到Git身份

su git

6.这时候已经是git用户了, 进入git的home目录

cd ~

7.下载gogs安装压缩包, 双引号里的下载地址替换为官方最新版本的下载地址

wget -c "https://dl.gogs.io/0.12.3/gogs_0.12.3_linux_amd64.tar.gz"

8.解压安装包

tar -zxf gogs_0.12.3_linux_amd64.tar.gz

9.进入gogs目录

cd gogs

10.启动安装程序

./gogs web

11.回到桌面, 用浏览器打开安装向导页面, 根据自己情况设置 需放开安全组和宝塔安全里面的3000端口

12.安装完成后, 回到终端, 退出当前的git用户

exit

13.为gogs添加服务,开机启动

# 创建服务配置文件
vim /lib/systemd/system/gogs.service

14.加入以下内容, 保存退出:

[Unit]
Description=Gogs
After=syslog.target
After=network.target
After=mysqld.service

[Service]
# Modify these two values and uncomment them if you have
# repos with lots of files and get an HTTP error 500 because
# of that
###
#LimitMEMLOCK=infinity
#LimitNOFILE=65535
Type=simple
User=git
Group=git
WorkingDirectory=/home/git/gogs
ExecStart=/home/git/gogs/gogs web
Restart=always
Environment=USER=git HOME=/home/git

[Install]
WantedBy=multi-user.target

15.设置开机启动

systemctl enable gogs.service

16.并手动启动服务

systemctl start gogs

17.查看服务状态

systemctl status gogs

18.在宝塔面板上配置域名访问(反向代理)
一步一步教你Gogs 安装和配置
19.这个时候就可以通过域名访问了, https证书在宝塔界面配置部署即可, 不用改gogs配置
使用域名访问搭建好的gogs
一步一步教你Gogs 安装和配置