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

相关推荐
瞬间&永恒~3 分钟前
【MySQL】 InnoDB 锁等待排查与并发压测实验
运维·数据库·mysql
江湖有缘26 分钟前
Docker实战 | 使用Docker部署Donetick任务与家务管理应用
运维·docker·容器
流星白龙39 分钟前
【Docker】4.NameSpace空间隔离实战
java·运维·docker
有续技术1 小时前
哈斯 (Haas) 机床 IP、端口号配置内容总结
运维·服务器
小张同学a.2 小时前
LAMP架构2
linux·运维·网络·架构·负载均衡
千河殇 多想和她2 小时前
如何在Reaonix中使用CodeGraph以及CodeGraph效果实测经验分享
linux·运维·ubuntu
VortMall2 小时前
出海引流运维双升级|VortMall微服务商城系统v1.3.12 升级更新
运维·微服务·facebook
心念枕惊2 小时前
新写了个直播录制工具,可录制抖音快手斗鱼直播
运维·服务器·数据库
躺不平的理查德2 小时前
CMAKE备忘录
linux·运维·服务器
9624562 小时前
跨域与私有网络访问限制排查实录
运维·服务器·网络