阿里云 ECS 搭建 Gitea 以及配置 Nginx 代理开启 https 和二级域名访问

一、创建用户

sudo useradd git

二、安装 git

sudo dnf install -y git

三、创建数据库

mysql -u root -p
CREATE USER 'gitea'@'%' IDENTIFIED BY '123456';
CREATE DATABASE gitea CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_bin';
GRANT ALL PRIVILEGES ON gitea.* TO 'gitea';
FLUSH PRIVILEGES;

四、安装及配置 Gitea

4.1 创建工作目录

sudo mkdir -p /opt/gitea/{custom,data,log,conf,bin}
cd /opt/gitea/bin/
sudo wget -O gitea https://dl.gitea.com/gitea/1.22.1/gitea-1.22.1-linux-amd64
sudo chmod +x gitea
sudo chown -R git:git /opt/gitea
sudo chmod -R 750 /opt/gitea

4.2 创建服务

sudo vim /etc/systemd/system/gitea.service
[Unit]
Description=Gitea (Git with a cup of tea)
After=network.target
# Don't forget to add the database service dependencies
Wants=mysqld.service
After=mysqld.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]
# Uncomment the next line if you have repos with lots of files and get a HTTP 500 error because of that
# LimitNOFILE=524288:524288
RestartSec=2s
Type=simple
User=git
Group=git
WorkingDirectory=/opt/gitea/
# If using Unix socket: tells systemd to create the /run/gitea folder, which will contain the gitea.sock file
# (manually creating /run/gitea doesn't work, because it would not persist across reboots)
#RuntimeDirectory=gitea
ExecStart=/opt/gitea/bin/gitea web --config /opt/gitea/conf/app.ini
Restart=always
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/opt/gitea
# If you install Git to directory prefix other than default PATH (which happens
# for example if you install other versions of Git side-to-side with
# distribution version), uncomment below line and add that prefix to PATH
# Don't forget to place git-lfs binary on the PATH below if you want to enable
# Git LFS support
#Environment=PATH=/path/to/git/bin:/bin:/sbin:/usr/bin:/usr/sbin
# If you want to bind Gitea to a port below 1024, uncomment
# the two values below, or use socket activation to pass Gitea its ports as above
#CapabilityBoundingSet=CAP_NET_BIND_SERVICE
#AmbientCapabilities=CAP_NET_BIND_SERVICE
# In some cases, when using CapabilityBoundingSet and AmbientCapabilities option, you may want to
# set the following value to false to allow capabilities to be applied on gitea process. The following
# value if set to true sandboxes gitea service and prevent any processes from running with privileges
# in the host user namespace.
#PrivateUsers=false
[Install]
WantedBy=multi-user.target
sudo systemctl start gitea
sudo systemctl enable gitea

访问地址 http://ip:3000

五、配置 Nginx 代理

如果直接通过端口访问 Gitea,则不需要这一步。如果自己有域名和SSL证书,可以做这一步开启https + 二级域名的方式访问 Gitea。

配置文件中的 example.com 替换成自己的域名,记得上传证书到 /etc/nginx/cert 目录下

sudo vim /etc/nginx/conf.d/gitea.conf
server {
    listen       443 ssl http2;
    listen       [::]:443 ssl http2;
    server_name  git.example.com;
    ssl_certificate "/etc/nginx/cert/example.com.crt";
    ssl_certificate_key "/etc/nginx/cert/example.com.key";
    ssl_session_cache shared:SSL:1m;
    ssl_session_timeout  10m;
    ssl_ciphers PROFILE=SYSTEM;
    ssl_prefer_server_ciphers on;
    location / {
        proxy_pass http://127.0.0.1:3000/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
sudo systemctl restart nginx

访问地址 https://二级域名

下载完成后用Goland打开,在项目根目录下使用以下命令安装各种前端依赖,下载好的依赖在项目根目录下生的目录中 然后通过以下目录构建后端代码 构建完成后,会在项目根目录下生成可执行文件,我们使用以下命令来启动项目 启动成功后我们访问本机的3000端口,可以看到如下界面:[外链图片转存中…(img-sQQUVKJn-1655878255146)]这里我们配置我们所安装的mysql数据库和密码即可,这里的数据
使用docker搭建最新版本的gitea,并配置HTTPS访问 文章目录使用docker搭建最新版本的gitea,并配置HTTPS访问简介官网docker拉取镜像运行镜像参数命令运行新建仓库配置HTTPS 文章所涉及的资料来自互联网整理和个人总结,意在于个人学习和经验汇总,如有什么地方侵权,请联系本人删除,谢谢! 之前有搭建gitlab,不过配置要求高,而且使用docker搭建之后各种问题,所以还是使用轻一点的git服务器,也够用了。 gitea docker拉取镜像
nginx 反向代理gitea踩坑前言默认反向代理解决方法完整代理配置 作为giteaForBT开发者,最近有用户遇到了一个反向代理的坑,那就是代理后能访问也能克隆,但是push数据量一大就会出现Request Entity Too Large报错,最后查了好多资料找到解决方案,特此做个记录。 默认反向代理 location ~* proxy_pass http://localhost:3000; proxy_set_header Host $host; 年轻人就得好好学习,不能这么颓废 最近做项目练练手,用到了github, 但是github访问速度是真的慢啊,下载项目,下载一天了。所以呢,我是个成熟的人了,只好自己搭建个私服自己用喽,而且我有阿里云免费领的半年的es服务器,就搭建在自己的阿里云 一、git介绍 百度百科: GitHub 是一个面向开源及私有软件项目的托管平台,因为只支持 Git 作为唯一的版本库格式进行托管,故名 GitHub。 Github地址:https://github.com/go-gitea/g