【运维】部署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

相关推荐
Tipriest_12 分钟前
离线进行apt安装的过程(在只能本地传输的ubuntu主机上使用apt安装)
linux·运维·ubuntu·apt·install·deb
love530love29 分钟前
Windows 如何更改 ModelScope 的模型下载缓存位置?
运维·人工智能·windows·python·缓存·modelscope
什么蜜桃绵绵冰1 小时前
linux易错题
linux·运维·服务器
GottdesKrieges1 小时前
obd运维OceanBase数据库的常见场景
运维·数据库·oceanbase
云和数据.ChenGuang1 小时前
`neutron router-gateway-set` 操作失败的可能原因及解决方案
运维·gateway·运维技术总结·运维技术
Leinwin1 小时前
微软Fabric重塑数据管理:Forrester报告揭示高ROI
运维·microsoft·fabric
胡耀超1 小时前
基于Docker的GPU版本飞桨PaddleOCR部署深度指南(国内镜像)2025年7月底测试好用:从理论到实践的完整技术方案
运维·python·docker·容器·ocr·paddlepaddle·gpu
FIT2CLOUD飞致云8 小时前
里程碑 | 1Panel开源面板GitHub Star数量突破30,000个!
运维·开源
FIT2CLOUD飞致云8 小时前
支持MySQL、PostgreSQL和Redis集群部署,1Panel开源面板v2.0.5版本发布
运维·开源
南玖yy9 小时前
Linux 桌面市场份额突破 5%:开源生态的里程碑与未来启示
linux·运维·服务器·汇编·科技·开源·gradle