当前位置: 首页 > Linux

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

时间:2023-04-06 11:42:46 Linux

Gogs的目标是打造最简单、最快速、最简单的自助式Git服务搭建方式。使用Go语言开发使得Gogs可以通过独立的二进制文件进行分发,并支持Go语言支持的所有平台,包括Linux、MacOSX、Windows和ARM平台。环境Centos8gogs_0.11.91creategituser[root@localhost~]#useraddgit[root@localhost~]#echo'123456'|passwd--stdingitChangingpasswordforusergit.passwd:allauthenticationtokensupdatedsuccessfully.为git用户设置sudo[root@localhost~]#visudogitALL=(ALL)NOPASSWD:ALL下载并配置基础环境[root@localhost~]#yum-yinstalltarwgetgitmariadbmariadb-server设置mariadb启动和启动mariadb服务[root@localhost~]#systemctlenablemariadb--nowcreategogsdatabase切换到git用户[root@localhost~]#su-gitcreatedatabase[git@localhost~]$mysql-uroot-e"CREATE数据库如果不存在gogsCHARACTERSETutf8mb4COLLATEutf8mb4_general_ci;"[git@localhost~]$mysql-uroot-e"showdatabases;"Databasegogsinformation_schemamysqlperformance_schema创建数据库gogs用户并授予对gogs数据库的访问权限:[git@localhost~]$mysql-uroot-e"createusergogs;grantallprivilegesongogs.*togogs@'%'identifiedby'gogs123';"查看是否添加了用户gogs,是否授予了所有访问权限。[git@localhost~]$mysql-uroot-e"selectHost,User,Passwordfrommysql.user;showgrantsforgogs@'%';"从gogs官网下载gogs安装包https://gogs.io/docs/installa...下载对应操作系统的安装包。[git@localhost~]$wgethttps://dl.gogs.io/0.11.91/go...[git@localhost~]$tarxvfgogs_0.11.91_linux_amd64.tar.gz启动gogs并打开端口防火墙[git@localhostgogs]$sudofirewall-cmd--permanent--add-port=3000/tcpsuccess[git@localhostgogs]$sudofirewall-cmd--reloadsuccess[git@localhost~]$/home/git/gogs/gogsweb打开浏览器,输入服务器的IP地址,端口为3000。数据库用户和密码,使用刚刚创建的。“ApplicationURL”填写gogs服务器的ip地址。然后单击立即安装。之后,转到登录屏幕,我们可以创建一个新用户。转到注册页面并注册用户。注册完成后登录,我们可以点击我的仓库创建第一个仓库。复制仓库地址,然后在自己的操作系统中下载仓库,在仓库中创建描述文件,上传到远程仓库。[root@localhost~]#gitclonehttp://192.168.60.137:3000/user01/example01.gitCloninginto'example01'...警告:您似乎克隆了一个空存储库。[root@localhost~]#cdexample01/[root@localhostexample01]#echo"这是example01的README">README.md[root@localhostexample01]#gitadd.[root@localhostexample01]#gitconfig--globaluser.nameuser01[root@localhostexample01]#gitconfig--globaluser.emailuser01@example.com[root@localhostexample01]#gitcommit-m"addaREADME.md"[master(root-commit)9d7df1d]添加README.md1文件已更改,1插入(+)创建模式100644README.md[root@localhostexample01]#gitpushEnumeratingobjects:3,done.Countingobjects:100%(3/3),done.Writingobjects:100%(3/3),240字节|240.00KiB/s,完成。总计3(增量0),重复使用0(增量0)“http://192.168.60.137:3000”的用户名:“http://user01@192.168.60.137:3000”的user01密码:到http://192.168.60.137:3000/user01/example01.git[newbranch]master->master远程仓库,可以看到上传成功总结一下部署Gogs的方式。您还可以使用基于Docker、Vagrant和Kubernetes的HelmCharts进行安装。