【运维】部署Gitea

部署Gitea

Gitea文档

系统:Ubuntu 20.04.6 LTS

步骤:

  1. 准备数据库
    • 使用内置 SQLite,无需额外准备。
  2. 下载安装
    • 下载最新版本的 Gitea 并安装:
bash 复制代码
wget -O gitea https://dl.gitea.com/gitea/@version@/gitea-@version@-linux-amd64
chmod +x gitea
gitea --version
cp gitea /usr/local/bin/gitea
  1. 创建用户
    • 创建专用用户 git
shell 复制代码
adduser \  
--system \  
--shell /bin/bash \  
--gecos 'Git Version Control' \  
--group \  
--disabled-password \  
--home /home/git \  
git
  1. 创建工作路径
    • 设置 Gitea 的工作目录和配置路径:
shell 复制代码
mkdir -p /var/lib/gitea/{custom,data,log}  
chown -R git:git /var/lib/gitea/  
chmod -R 750 /var/lib/gitea/  
mkdir /etc/gitea  
chown root:git /etc/gitea  
chmod 770 /etc/gitea
  1. 配置和启动服务
    • 创建 systemd 服务文件 /etc/systemd/system/gitea.service
shell 复制代码
sudo vim /etc/systemd/system/gitea.service
复制代码
- 添加以下内容:
txt 复制代码
# gitea.service

[Unit]
Description=Gitea (Git with a cup of tea)
After=syslog.target
After=network.target
# Requires and starts the database service (uncomment if necessary)
# Requires=mysql.service
# After=mysql.service
# Requires=postgresql.service
# After=postgresql.service
# Requires=mariadb.service
# After=mariadb.service

[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
复制代码
- 启用并启动 Gitea 服务:
shell 复制代码
sudo systemctl enable gitea  
sudo systemctl start gitea
  1. 配置
  • 在浏览器中访问 http://localhost:3000 进行初始配置。
  • 可以使用宝塔面板设置反向代理,让 Gitea 可以通过自定义域名访问。

示例:gitea.beyondxin.top

相关推荐
^—app5668664 小时前
游戏运存小启动不起来临时解决方法
运维·服务器
Ujimatsu4 小时前
虚拟机安装Debian 13.x及其常用软件(2026.4)
linux·运维·ubuntu
志栋智能5 小时前
超自动化安全:构建智能安全运营的核心引擎
大数据·运维·服务器·数据库·安全·自动化·产品运营
Edward111111117 小时前
4月28日防火墙问题
linux·运维·服务器
想学后端的前端工程师7 小时前
【补充内外网突然不通的情况】
运维·服务器
面汤放盐7 小时前
何时使用以及何时不应使用微服务:没有银弹
java·运维·云计算
子琦啊7 小时前
【算法复习】字符串 | 两个底层直觉,吃透高频题
linux·运维·算法
AOwhisky8 小时前
Kubernetes 学习笔记:集群管理、命名空间与 Pod 基础
linux·运维·笔记·学习·云原生·kubernetes
小龙在慢慢变强..9 小时前
目录结构(FHS 标准)
linux·运维·服务器