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

相关推荐
小张成长计划..21 分钟前
【Linux】27:日志
linux·运维·服务器
时间售卖铺27 分钟前
Nginx 反向代理
运维·nginx·云原生
life码农28 分钟前
Nginx location 优先级详解:匹配规则、修饰符与完整代码示例
运维·nginx
我命由我123451 小时前
Python 开发 - Python 虚拟环境
运维·开发语言·后端·python·http·https·java-ee
dlhto1 小时前
Windows 使用 Rufus 制作 AlmaLinux 10.2 启动 U 盘:从 ISO 下载到服务器安装
运维·服务器·windows
软件派1 小时前
Beam.Win 自动化办公与业务流程提效指南
运维·自动化
澜山奕秋2 小时前
Rhcsa 二
linux·运维·服务器
无足鸟ICT2 小时前
【RHCA+】yum源配置(软件仓库)
linux·运维
dk_tjy2 小时前
迪康加密系统技术解析:驱动层透明加密的机制、策略与工程权衡
运维·安全·网络安全·终端安全管理·数据防泄漏
Initialize-le3 小时前
服务器时间不准?NTP 时钟同步五步排查
运维·服务器