设为首页收藏本站language→→ 语言切换

鸿鹄论坛

 找回密码
 论坛注册

QQ登录

先注册再绑定QQ

查看: 703|回复: 0
收起左侧

Centos8 安装 Gogs 代码仓库管理工具

[复制链接]
发表于 2021-3-12 13:19:32 | 显示全部楼层 |阅读模式
Gogs 的目标是打造一个最简单、最快速和最轻松的方式搭建自助 Git 服务。使用 Go 语言开发使得 Gogs 能够通过独立的二进制分发,并且支持 Go 语言支持的所有平台,包括 Linux、Mac OS X、Windows 以及 ARM 平台。
环境
创建git用户
[root@localhost ~]# useradd git[root@localhost ~]# echo '123456'|passwd --stdin gitChanging password for user git.passwd: all authentication tokens updated successfully.

为git用户设置sudo

[root@localhost ~]# visudogit     ALL=(ALL)       NOPASSWD: ALL


                               
登录/注册后可看大图

下载并配置基本环境
[root@localhost ~]# yum -y install tar wget git mariadb mariadb-server

设置mariadb开机启动,并启动mariadb服务

[root@localhost ~]# systemctl enable mariadb --now创建gogs数据库
# 切换到git用户[root@localhost ~]# su - git# 创建数据库[git@localhost ~]$ mysql -u root -e "CREATE DATABASE IF NOT EXISTS gogs CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;"[git@localhost ~]$ mysql -u root -e "show databases;"+--------------------+| Database           |+--------------------+| gogs               || information_schema || mysql              || performance_schema |+--------------------+


                               
登录/注册后可看大图

创建数据库gogs用户,并授予访问gogs数据库权限:

[git@localhost ~]$ mysql -u root -e "create user gogs; grant all privileges on gogs.* to gogs@'%' identified by 'gogs123';"# 查看用户gogs是否添加,是否授予所有访问权。[git@localhost ~]$ mysql -u root -e "select Host,User,Password from mysql.user; show grants for gogs@'%';"


                               
登录/注册后可看大图

下载gogs安装包

从gogs的官网 https://gogs.io/docs/installation/install_from_binary 下载对应操作系统的安装包。


                               
登录/注册后可看大图

[git@localhost ~]$ wget https://dl.gogs.io/0.11.91/gogs_0.11.91_linux_amd64.tar.gz[git@localhost ~]$ tar xvf gogs_0.11.91_linux_amd64.tar.gz 启动gogs并开放防火墙的端口
[git@localhost gogs]$ sudo firewall-cmd --permanent --add-port=3000/tcpsuccess[git@localhost gogs]$ sudo firewall-cmd --reloadsuccess[git@localhost ~]$ /home/git/gogs/gogs web


                               
登录/注册后可看大图

打开浏览器输入服务器的ip地址,端口是3000。数据库用户和密码,使用刚才创建的。“应用URL”填写gogs服务器的ip地址。然后点击立即安装。


                               
登录/注册后可看大图

之后,进入登录界面,我们可以创建一个新用户。


                               
登录/注册后可看大图

进入注册页面,注册用户。


                               
登录/注册后可看大图

注册完成,登录进去,我们可以点我的仓库,创建第一个仓库。


                               
登录/注册后可看大图


                               
登录/注册后可看大图

复制仓库地址,然后再自己的操作系统中下载该仓库


                               
登录/注册后可看大图

在仓库中创建一个描述文件,并上传到远程仓库中。

[root@localhost ~]# git clone http://192.168.60.137:3000/user01/example01.gitCloning into 'example01'...warning: You appear to have cloned an empty repository.[root@localhost ~]# cd example01/[root@localhost example01]# echo "This is example01's README" > README.md[root@localhost example01]# git add .[root@localhost example01]# git config --global user.name user01[root@localhost example01]# git config --global user.email user01@example.com[root@localhost example01]# git commit -m "add a README.md"[master (root-commit) 9d7df1d] add a README.md 1 file changed, 1 insertion(+) create mode 100644 README.md[root@localhost example01]# git pushEnumerating objects: 3, done.Counting objects: 100% (3/3), done.Writing objects: 100% (3/3), 240 bytes | 240.00 KiB/s, done.Total 3 (delta 0), reused 0 (delta 0)Username for 'http://192.168.60.137:3000': user01Password for 'http://user01@192.168.60.137:3000': To http://192.168.60.137:3000/user01/example01.git * [new branch]      master -> master

远程仓库中可以看到上传成功。


                               
登录/注册后可看大图

总结

部署Gogs的方式还有可以使用Docker、Vagrant、基于 Kubernetes 的 Helm Charts等方式安装。

本文原创地址:https://www.linuxprobe.com/centos8-gogs-git.html编辑:倪家兴,审核员:逄增宝


您需要登录后才可以回帖 登录 | 论坛注册

本版积分规则

QQ|Archiver|手机版|小黑屋|sitemap|鸿鹄论坛 ( 京ICP备14027439号 )  

GMT+8, 2024-3-29 20:51 , Processed in 0.051566 second(s), 7 queries , Redis On.  

  Powered by Discuz!

  © 2001-2024 HH010.COM

快速回复 返回顶部 返回列表