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

相关推荐
waves浪游4 分钟前
基础开发工具(下)
linux·运维·服务器·开发语言·c++
Miki Makimura7 分钟前
KVStore 多行文章型键值扩展解析:切片存储与客户端多行交互
运维·服务器·网络·学习
春风霓裳1 小时前
ubuntu磁盘管理、磁盘扩容
linux·运维·ubuntu
广州服务器托管1 小时前
WIN11.26H1.27982.1中简优化版 45进程(2025.11.8)
运维·人工智能·计算机网络·云计算·可信计算技术
拾心212 小时前
【云运维】LNMP 架构部署与应用
运维·架构
亮子AI3 小时前
【Nginx】怎样清除 Nginx 的缓存?
运维·nginx·缓存
vvw&3 小时前
如何在 Ubuntu 24.04 上安装和使用 AdGuard
linux·运维·服务器·ubuntu·adguard
weixin_453253653 小时前
python+playwright自动化如何解决文件上传问题
运维·自动化
King's King3 小时前
超详细的自动化立体仓库技术标书-模板
运维·自动化
TTBIGDATA3 小时前
【Ambari开启Kerberos】Step1-KDC服务初始化安装-适合Ubuntu
运维·数据仓库·hadoop·ubuntu·ambari·hdp·bigtop