

从零开始搭建gitea代码管理平台 - 水上云天
source link: https://www.cnblogs.com/zzugyl/p/16666343.html
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.

Gitea,一款极易搭建的Git自助服务。如其名,Git with a cup of tea。跨平台的开源服务,支持Linux、Windows、macOS和ARM平台。配置要求低,甚至可以运行在树莓派上。

搭建之前,首先提示两个坑:
1、gitea不支持Centos6和更早的版本内核。
2、gitea不能在root下运行,必须是普通用户权限。
不确定是否使用gitea服务的,可以看一下官网功能对比。
https://docs.gitea.io/zh-cn/comparison/
一、选择安装环境
我这边是物理主机服务器,安装的Centos7。
[xxx@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
[xxx@localhost ~]# uname -sr
Linux 3.10.0-1160.62.1.el7.x86_64
二、下载gitea
这个很简单,直接去官网下载二进制或者去github上下载。
[xxx@localhost gitea]# wget -O gitea https://dl.gitea.io/gitea/1.16.8/gitea-1.16.8-linux-amd64
[xxx@localhost gitea]# chmod +x gitea
这里我用二进制方式运行的。也可以用docker方式运行。
三、安装git
安装git,并配置环境变量,否则失败。
[xxx@localhost data]# yum install git
创建一个git用户,专门用来管理git相关服务。
sudo useradd \
--system \
--shell /bin/bash \
--comment 'Git Version Control' \
--create-home \
--home /home/git \
git
[xxx@localhost data]# passwd git
Changing password for user git.
New password:
四、创建gitea相关目录
创建gitea工作目录:
[xxx@localhost data]# pwd
/data
[xxx@localhost data]# mkdir gitea
[xxx@localhost data]# chown -R git:git gitea/
[xxx@localhost data]# ls -lth
total 0
drwxr-xr-x 2 git git 6 Jun 1 16:02 gitea
创建gitea 可执行文件存放目录
[xxx@localhost opt]# chown -R git:git gitea/
[xxx@localhost opt]# ls -lth
total 0
drwxr-xr-x 2 git git 19 May 31 16:34 gitea
五、测试gitea服务
[xxx@localhost gitea]$ ./gitea web
从web打开 http://服务器IP:3000/ ,可进行配置更改和安装。
下载服务配置文件
sudo wget https://raw.githubusercontent.com/go-gitea/gitea/master/contrib/systemd/gitea.service -P /etc/systemd/system/
更改gitea配置文件
[xxx@localhost system]# vim /etc/systemd/system/gitea.service
# 更改路径如下:
WorkingDirectory=/data/gitea/
# If using Unix socket: tells systemd to create the /run/gitea folder, which will contain the gitea.sock file
# (manually creating /run/gitea doesn't work, because it would not persist across reboots)
#RuntimeDirectory=gitea
ExecStart=/opt/gitea/gitea web --config /data/gitea/app.ini
Restart=always
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/data/gitea
启动gitea服务
[xxx@localhost opt]# systemctl daemon-reload
[xxx@localhost opt]# systemctl enable --now gitea
[xxx@localhost opt]#
[xxx@localhost opt]# systemctl status gitea
● gitea.service - Gitea (Git with a cup of tea)
Loaded: loaded (/etc/systemd/system/gitea.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2022-06-01 17:19:01 CST; 3s ago
Main PID: 10567 (gitea)
Tasks: 29
Memory: 153.5M
CGroup: /system.slice/gitea.service
└─10567 /opt/gitea/gitea web --config /data/gitea/app.ini
Jun 01 17:19:01 localhost.localdomain gitea[10567]: 2022/06/01 17:19:01 ...s/install/setting.go:21:PreloadSettings() [I] AppPa.../giteaJun 01 17:19:01 localhost.localdomain gitea[10567]: 2022/06/01 17:19:01 ...s/install/setting.go:22:PreloadSettings() [I] AppWo.../giteaJun 01 17:19:01 localhost.localdomain gitea[10567]: 2022/06/01 17:19:01 ...s/install/setting.go:23:PreloadSettings() [I] Custo...customJun 01 17:19:01 localhost.localdomain gitea[10567]: 2022/06/01 17:19:01 ...s/install/setting.go:24:PreloadSettings() [I] Log p...ea/logJun 01 17:19:01 localhost.localdomain gitea[10567]: 2022/06/01 17:19:01 ...s/install/setting.go:25:PreloadSettings() [I] Confi...pp.iniJun 01 17:19:01 localhost.localdomain gitea[10567]: 2022/06/01 17:19:01 ...s/install/setting.go:26:PreloadSettings() [I] Prepa...l pageJun 01 17:19:01 localhost.localdomain gitea[10567]: 2022/06/01 17:19:01 ...s/install/setting.go:29:PreloadSettings() [I] SQLit...portedJun 01 17:19:02 localhost.localdomain gitea[10567]: 2022/06/01 17:19:02 cmd/web.go:208:listen() [I] Listen: http://0.0.0.0:3000
Jun 01 17:19:02 localhost.localdomain gitea[10567]: 2022/06/01 17:19:02 cmd/web.go:212:listen() [I] AppURL(ROOT_URL): http://l...:3000/Jun 01 17:19:02 localhost.localdomain gitea[10567]: 2022/06/01 17:19:02 ...s/graceful/server.go:61:NewServer() [I] Starting ne... 10567Hint: Some lines were ellipsized, use -l to show in full.
其他的更改:
仓库根目录 /data/gitea/gitea-repositories
LFS根目录 /data/gitea/lfs

然后添加一个添加管理员账号:
用户名 youname
密码 youcode
Email: [email protected]
点击开始安装,很快就搞定了。
七、可以愉快的玩耍了
由于更换了端口号,现在用浏览器打开新的地址
http://server_ip:new_port/

接下来,创建组织,创建团队,注册用户账号。玩起来。
Recommend
-
58
110 Comments Ηurrah! Fial...
-
6
水上演练 备战汛期
-
1
迪士尼世界之水上公园 网站首页 往昔追忆 浮光掠影 科学园地 技术广角 笑傲江湖 翻译作品 站长微博 评论选录 欢 迎 访 问 卢 昌 海 个 人 主 页 除了自己的无知...
-
5
查看: 1176|回复: 9 [城市建设] 他山之石:铜仁开通水上公交
-
0
欧雷说:「这要坐水上巴士的人多得有点夸张哟」 欧雷 发表于 2022-04-03 15:13 微信扫一扫:分享微信里点“发现”,扫一下二维码便可将本文分享至朋友...
-
13
小米推出「2022中国影像辞典」,被水上流动影像展治愈 作者: Emily ...
-
11
都是做混合玩法,有的月流水上亿、有的疯狂买量却进不了分榜Top100 ...
-
5
水上交通拥抱绿色又一家,Hurtigruten Norway 推出电动游轮2023/06/11 17:26|By
-
4
拥抱绿色水上交通,Taiga Motors 推出第二款电动摩托艇2023/08/18 16:44|By
-
7
编辑|在洲一个全新的“水上独角兽”来了。美国电动船初创公司Arc Boats,刚刚交付了限量版电动船Arc One,同时宣布,最新B轮融资中拿到了7000万美元,折合人民币5.1亿元。Arc成立时间并不长,这家电动船初创公司成立于2021年初,其最大的目标就...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK