本篇内容介绍了“Centos8怎么安装Gogs托管服务”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

Dogs是一款极易搭建的自助 Git 服务,具有易安装,跨平台,轻量级的特点。可以根据操作系统平台通过 二进制运行,还可以通过 Docker 或 Vagrant,以及包管理安装,任何 Go 语言 支持的平台都可以运行

环境
Centos8
gogs_0.11.91
创建git用户

[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--now创建gogs数据库

#切换到git用户[root@localhost~]#su-git#创建数据库[git@localhost~]$mysql-uroot-e"CREATEDATABASEIFNOTEXISTSgogsCHARACTERSETutf8mb4COLLATEutf8mb4_general_ci;"[git@localhost~]$mysql-uroot-e"showdatabases;"+--------------------+|Database|+--------------------+|gogs||information_schema||mysql||performance_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/installation/install_from_binary 下载对应操作系统的安装包。

[git@localhost~]$wgethttps://dl.gogs.io/0.11.91/gogs_0.11.91_linux_amd64.tar.gz[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。数据库用户和密码,使用刚才创建的。“应用URL”填写gogs服务器的ip地址。然后点击立即安装。

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

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

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

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

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

[root@localhost~]#gitclonehttp://192.168.60.137:3000/user01/example01.gitCloninginto'example01'...warning:Youappeartohaveclonedanemptyrepository.[root@localhost~]#cdexample01/[root@localhostexample01]#echo"Thisisexample01'sREADME">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]addaREADME.md1filechanged,1insertion(+)createmode100644README.md[root@localhostexample01]#gitpushEnumeratingobjects:3,done.Countingobjects:100%(3/3),done.Writingobjects:100%(3/3),240bytes|240.00KiB/s,done.Total3(delta0),reused0(delta0)Usernamefor'http://192.168.60.137:3000':user01Passwordfor'http://user01@192.168.60.137:3000':Tohttp://192.168.60.137:3000/user01/example01.git*[newbranch]master->master

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

“Centos8怎么安装Gogs托管服务”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!