Gitea 二进制版本 安装配置
使用Gitea的二进制版本在Linux上搭建自己的git服务器
Categories:
关于Gitea
Gitea 是一个自己托管的Git服务程序。他和GitHub, Bitbucket or Gitlab等比较类似。他是从 Gogs 发展而来
Gitea的首要目标是创建一个极易安装,运行非常快速,安装和使用体验良好的自建 Git 服务。 采用Go作为后端语言,只生成一个可执行程序即可。
并且他还支持跨平台,支持 Linux, macOS 和 Windows 以及各种架构,除了x86,amd64,还包括 ARM 和 PowerPC。
准备工作
1
2# .bashrc 中 配置环境变量
3export GITEA_WORK_DIR=/var/lib/gitea/
4
5
6# 建立执行用户
7groupadd --system git
8useradd \
9 --system \
10 --shell /bin/bash \
11 --comment 'Git Version Control' \
12 --gid git \
13 --home-dir /home/git \
14 --create-home \
15 git
16
17# 建立工作路径
18mkdir -p /var/lib/gitea/{custom,data,log}
19chown -R git:git /var/lib/gitea/
20chmod -R 750 /var/lib/gitea/
21mkdir /etc/gitea
22chown root:git /etc/gitea
23chmod 770 /etc/gitea
gitea 二进制版本安装
1
2wget -O gitea https://dl.gitea.com/gitea/1.20.3/gitea-1.20.3-linux-amd64
3chmod +x gitea
4cp gitea /usr/local/bin/gitea
5
6
7# 首次运行
8su -l git
9GITEA_WORK_DIR=/var/lib/gitea/ /usr/local/bin/gitea web -c /etc/gitea/app.ini
Gitea 服务配置文件
1sudo vim /etc/systemd/system/gitea.service
1[Unit]
2Description=Gitea (Git with a cup of tea)
3After=syslog.target
4After=network.target
5
6[Service]
7# Uncomment the next line if you have repos with lots of files and get a HTTP 500 error because of that
8# LimitNOFILE=524288:524288
9RestartSec=2s
10Type=notify
11User=git
12Group=git
13WorkingDirectory=/var/lib/gitea/
14# If using Unix socket: tells systemd to create the /run/gitea folder, which will contain the gitea.sock file
15# (manually creating /run/gitea doesn't work, because it would not persist across reboots)
16#RuntimeDirectory=gitea
17ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini
18Restart=always
19Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea
20WatchdogSec=30s
21
22[Install]
23WantedBy=multi-user.target
1sudo systemctl enable gitea
2sudo systemctl start gitea