关于linux:Centos8-安装-Gogs-代码仓库管理工具

22次阅读

共计 2475 个字符,预计需要花费 7 分钟才能阅读完成。

Gogs 的指标是打造一个最简略、最疾速和最轻松的形式搭建自助 Git 服务。应用 Go 语言开发使得 Gogs 可能通过独立的二进制散发,并且反对 Go 语言反对的所有平台,包含 Linux、Mac OS X、Windows 以及 ARM 平台。

环境

  • Centos8
  • gogs_0.11.91

创立 git 用户

[root@localhost ~]# useradd git
[root@localhost ~]# echo ‘123456’|passwd –stdin git
Changing password for user git.
passwd: all authentication tokens updated successfully.

为 git 用户设置 sudo

[root@localhost ~]# visudo
git 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/installa… 下载对应操作系统的安装包。

[git@localhost ~]$ wget https://dl.gogs.io/0.11.91/go…
[git@localhost ~]$ tar xvf gogs_0.11.91_linux_amd64.tar.gz

启动 gogs 并凋谢防火墙的端口

[git@localhost gogs]$ sudo firewall-cmd –permanent –add-port=3000/tcp
success
[git@localhost gogs]$ sudo firewall-cmd –reload
success
[git@localhost ~]$ /home/git/gogs/gogs web


关上浏览器输出服务器的 ip 地址,端口是 3000。数据库用户和明码,应用方才创立的。“利用 URL”填写 gogs 服务器的 ip 地址。而后点击立刻装置。


之后,进入登录界面,咱们能够创立一个新用户。


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


注册实现,登录进去,咱们能够点我的仓库,创立第一个仓库。


复制仓库地址,而后再本人的操作系统中下载该仓库


在仓库中创立一个形容文件,并上传到近程仓库中。

[root@localhost ~]# git clone http://192.168.60.137:3000/user01/example01.git
Cloning 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 push
Enumerating 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’: user01
Password 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 等形式装置。

正文完
 0