centos安装gitea,使用内置库

404 阅读2分钟

开启掘金成长之旅!这是我参与「掘金日新计划 · 12 月更文挑战」的第35天,点击查看活动详情

gitea是啥

官网的介绍如下:

Gitea的首要目标是创建一个极易安装,运行非常快速,安装和使用体验良好的自建 Git 服务。我们采用Go作为后端语言,这使我们只要生成一个可执行程序即可。并且他还支持跨平台,支持 Linux, macOS 和 Windows 以及各种架构,除了x86,amd64,还包括 ARM 和 PowerPC;

简单来说:

Gitea 是一款使用 Golang 编写的可自运营的代码管理工具。

Gitea 支持mysql , postgresmssqltidb 、sqlite3 多种数据库。 最简单的是直接使用 sqlite3; 本文章就直接使用内置的sqlite3数据库;

搭建的详细步骤如下:

创建文件夹,下载gitea

mkdir gitea

cd gitea

wget -O gitea https://dl.gitea.io/gitea/1.15.6/gitea-1.15.6-linux-amd64 --no-check-certificate

最后一个属性一定要加

修改权限:

chmod  +x gitea

启动:

./gitea web

访问: http://ip:3000/gitea

配置后会生成文件夹

在这里插入图片描述

设置gitea为服务:

wget https://raw.githubusercontent.com/go-gitea/gitea/master/contrib/systemd/gitea.service -P /etc/systemd/system/

下载gitea.service文件,并放到指定文件夹下;

修改gitea.service文件:

[Unit]
Description=Gitea (Git with a cup of tea)
After=syslog.target
After=network.target
###
# Don't forget to add the database service dependencies
###
#
#Wants=mysql.service
#After=mysql.service
#
#Wants=mariadb.service
#After=mariadb.service
#
#Wants=postgresql.service
#After=postgresql.service
#
#Wants=memcached.service
#After=memcached.service
#
#Wants=redis.service
#After=redis.service
#
###
# If using socket activation for main http/s
###
#
#After=gitea.main.socket
#Requires=gitea.main.socket
#
###
# (You can also provide gitea an http fallback and/or ssh socket too)
#
# An example of /etc/systemd/system/gitea.main.socket
###
##
## [Unit]
## Description=Gitea Web Socket
## PartOf=gitea.service
##
## [Socket]
## Service=gitea.service
## ListenStream=<some_port>
## NoDelay=true
##
## [Install]
## WantedBy=sockets.target
##
###

[Service]
# Modify these two values and uncomment them if you have
# repos with lots of files and get an HTTP error 500 because
# of that
###
#LimitMEMLOCK=infinity
#LimitNOFILE=65535
RestartSec=2s
Type=simple
User=root
Group=root
WorkingDirectory=/var/lib/gitea/

ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini
Restart=always
Environment=USER=root HOME=/home/gitea GITEA_WORK_DIR=/var/lib/gitea



[Install]
WantedBy=multi-user.target

启动gitea初始化

./gitea web

默认端口3000

访问页面 http://ip:3000 进入配置页面

如果提示没有安装git,使用以下命令,先安装git

yum install git

初始化完成后,会在指定目录生成app.ini配置文件, 默认目录为

/usr/local/bin/custom/conf

遇到的问题: 配置后无法启动,后来发现是有个目录不存在导致的; 执行命令:

mkdir /var/lib/gitea

部署完成