gitea安装

本文详细指导了如何从源码安装Git,创建git用户组和用户,以及配置并启动Gitea服务,包括个性化设置和系统自启动。重点介绍了Gitea的配置选项和注意事项。

 安装git

建议编译源码安装

tar -xvf git-2.44.0.tar.gz
cd git-2.44.0
make prefix=/usr/local/git all
make prefix=/usr/local/git install
git --verision
复制代码

创建 git 组和用户

groupadd git
useradd git -g git -s /bin/false
复制代码

下载 gitea 二进制文件,并修改权限

mkdir /usr/local/gitea
cd /usr/local/gitea
wget -O gitea https://dl.gitea.io/gitea/1.9.5/gitea-1.9.5-linux-amd64
chmod +x gitea
chown -R git:git /usr/local/gitea
复制代码

创建 gitea service 并启动

vim /etc/systemd/system/gitea.service
接着拷贝示例代码 gitea.service 并取消对任何需要运行在主机上的服务部分的注释,譬如 MySQL。

个人的配置文件:

[Unit]
Description=Gitea (Git with a cup of tea)
After=syslog.target
After=network.target

[Service]
RestartSec=2s
Type=simple
User=git
Group=git
WorkingDirectory=/usr/local/gitea/
ExecStart=/usr/local/gitea/gitea web -c /usr/local/gitea/custom/conf/app.ini
Restart=always
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/usr/local/gitea
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_BIND_SERVICE

[Install]
WantedBy=multi-user.target
复制代码

激活 gitea 并将它作为系统自启动服务

systemctl daemon-reload
systemctl start gitea
复制代码

gitea service 命令

#启动
systemctl start gitea
#关闭
systemctl stop gitea
#状态
systemctl status gitea
复制代码

接下来打开 http://localhost:3000 进行 install 即可,个人 install 设置

配置

修改自定义配置文件 custom/conf/app.ini ,这个文件的具体位置与你的设置有关。比如我是将他存放在 /usr/program/gitea/custom/conf/app.ini

完整的默认设置可以通过 app.ini.sample 查看。如果看到类似 %(X)s 字符,这是由 ini 提供的递归取值的特性。

### Gitea 安装教程 #### 环境准备 在开始之前,需确认服务器运行的是 Ubuntu 22.04 或其他兼容版本的 Linux 发行版。确保已更新系统的软件包列表并安装必要的依赖项[^1]。 ```bash sudo apt update && sudo apt upgrade -y sudo apt install curl wget git build-essential libssl-dev -y ``` #### 下载与安装 Gitea 访问官方发布页面获取最新稳定版本的二进制文件,并将其解压到指定目录下: ```bash wget https://dl.gitea.io/gitea/1.20.0/gitea-1.20.0-linux-amd64 chmod +x gitea-1.20.0-linux-amd64 sudo mv gitea-1.20.0-linux-amd64 /usr/local/bin/gitea ``` 设置启动脚本以便于管理服务状态[^2]: ```bash sudo tee /etc/systemd/system/gitea.service <<EOF [Unit] Description=Gitea (Git with a cup of tea) After=syslog.target After=network.target [Service] RestartSec=2s Type=simple User=gitea Group=gitea WorkingDirectory=/var/lib/gitea/ ExecStart=/usr/local/bin/gitea web --config /etc/gitea/conf/app.ini Restart=always Environment=USER=gitea HOME=/home/gitea [Install] WantedBy=multi-user.target EOF ``` 执行 `systemctl` 命令完成初始化配置过程: ```bash sudo systemctl daemon-reload sudo systemctl enable gitea sudo systemctl start gitea ``` #### 数据库连接设定 首次打开浏览器输入地址栏中的 URL 地址 http://<server-ip>:3000 ,按照提示填写相关信息来建立初始管理员账户以及关联 MySQL/MariaDB 或 SQLite 的数据存储位置[^3]。 #### 后续维护建议 定期备份重要资料以防丢失;调整防火墙规则仅允许特定 IP 范围内的客户端访问端口 3000 提升安全性。
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值