Linux 安装 Gitea.md

2023-12-13 06:25:49

### 从官网下载git 和 gitea

```
Git下载地址: https://mirrors.edge.kernel.org/pub/software/scm/git/
下载 git-2.43.0.tar.gz: https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.43.0.tar.gz

Gitea下载地址: https://dl.gitea.com/gitea/
下载 linux-arm64 的二进制包:https://dl.gitea.com/gitea/1.21.1/gitea-1.21.1-linux-arm64


```

### 安装git

```bash
yum install expat-devel

tar zxvf git-2.43.0.tar.gz
mv git-2.43.0 git
cd git
make prefix=/usr/local all
make prefix=/usr/local install
```

### 创建git用户

```bash
groupadd git
adduser --system --shell /bin/bash --comment 'Git Version Control' --home-dir /home/git --create-home git -g git
```

### 创建Gitea数据目录,并授权

```bash
# 存放仓库相关文件的目录
mkdir -p /var/lib/gitea/{custom,data,log}?
chown -R git:git /var/lib/gitea/?
chmod -R 750 /var/lib/gitea/
# 存放配置文件app.ini的目录
mkdir /etc/gitea
chown root:git /etc/gitea
chmod 770 /etc/gitea
```

### 将gitea程序移动到/usr/local/bin/目录下面

```bash
cd ~
mv gitea-1.21.1-linux-amd64 /usr/local/bin/gitea
chmod +x /usr/local/bin/gitea
```

### 将二进制注册为服务

```bash
cat > /etc/systemd/system/gitea.service << EOF
[Unit]
Description=Gitea
After=syslog.target
After=network.target

[Service]
RestartSec=2s
Type=simple
User=git
Group=git
WorkingDirectory=/var/lib/gitea/
ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini
Restart=always
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea

[Install]
WantedBy=multi-user.target
EOF
```

### 注册为开机自启并启动服务

```
sudo systemctl daemon-reload
sudo systemctl enable gitea
sudo systemctl start gitea
```

### 开放防火墙3000端口

```
firewall-cmd --zone=public --add-port=3000/tcp --permanent #添加端口
firewall-cmd --reload ? ?#重载
firewall-cmd --zone=public --query-port=3000/tcp ? ?#/查询端口开放是否成功
```

文章来源:https://blog.csdn.net/ZXJ_1223/article/details/134901665
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。