1

Gogs安装教程

 2 years ago
source link: https://shidawuhen.github.io/2022/04/05/Gogs%E5%AE%89%E8%A3%85%E6%95%99%E7%A8%8B/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Gogs安装教程

2022-04-05

Gogs是一款极易搭建的自助Git服务。本文讲解如何使用二进制方案在Centos上搭建Gogs,环境配置如下:

Centos:7.6

MySQL:8.0

首先下载二进制文件并安装:

# 下载gogs二进制
sudo wget https://dl.gogs.io/0.12.6/gogs_0.12.6_linux_amd64.zip
# 解压
unzip gogs_0.12.6_linux_amd64.zip

cd gogs/

./gogs web

# 访问 /install 以进行初始配置
http://122.51.225.162:3000/install

访问上述链接后,打开页面如下所示,我们分别进行配置:

image-20220404222252122

我使用的是MySQL数据库,数据库的安装可参考Airflow搭建与使用。首先创建DataBase,并设置字符集utf8_general_ci。为了安全可以创建单独的用户用于处理gogs服务。

CREATE DATABASE gogs CHARACTER SET utf8;
# 创建gogs用户用户
CREATE USER 'gogs'@'122.51.225.162' IDENTIFIED BY 'lll';
GRANT ALL PRIVILEGES ON *.* TO 'gogs'@'122.51.225.162';
FLUSH PRIVILEGES;

配置数据库主机、用户名、密码等信息。

image-20220404230208622

应用基本设置

应用基本设置只需要修改运行系统用户、域名、应用URL,其它采用默认值。

image-20220404230639161

管理员账号

配置管理员账号,让自己有所有权限。

image-20220404224139278

配置完上述信息后,点击立即安装,新的页面如下所示:

image-20220404230710722

用户可以创建新的仓库:

image-20220404231202361

image-20220404231241219

image-20220404231259750

用户要将仓库下载到本地,这需要配置密钥,具体操作如下:

ssh-keygen -t rsa -b 4096 -C "w****@163.com"
# 一路回车
cd ~/.ssh/
cat id_rsa.pub
# 将密钥添加到gogs上

image-20220404231407357

image-20220404231418660

image-20220404232327841

# 克隆仓库
git clone http://122.51.225.162:3000/shidawuhen/test.git
# 执行初始操作
touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin http://122.51.225.162:3000/shidawuhen/test.git
git push -u origin master

仓库需要多人维护,所以我们需要增加新的用户:

image-20220404232357548

image-20220404232435113

创建完用户后,将对应仓库增加协作者,新用户登录后即可看到对应的仓库

image-20220404232838765

gogs创建用户时,认证源使用的是本地,后续可继承openldap做登录认证。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK