准备数据库
-
MySQL
Ver 8.0.19 for Linux on x86_64
-
创建用户
gitea
# local
CREATE USER 'gitea' IDENTIFIED BY '112233@AbC';
# remote
CREATE USER 'gitea'@'192.0.2.10' IDENTIFIED BY '112233@AbC';
-
创建数据库
giteadb
CREATE DATABASE giteadb CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_unicode_ci';
-
授权
# local
GRANT ALL PRIVILEGES ON giteadb.* TO 'gitea';
# remote
GRANT ALL PRIVILEGES ON giteadb.* TO 'gitea'@'192.0.2.10';
# 刷新
FLUSH PRIVILEGES;
-
PostgreSQL
-
To-Do
二进制部署
wget -O gitea https://dl.gitea.io/gitea/1.11.1/gitea-1.11.0-linux-amd64
chmod +x gitea
cp gitea /usr/local/bin/
-
创建运行用户
adduser \
--system \
--shell /bin/bash \
--comment 'Git Version Control' \
--home /home/gitea \
--user-group \
gitea
-
准备目录及权限
mkdir -p /var/lib/gitea/{custom,data,log,ssl}
chown -R gitea:gitea /var/lib/gitea/
chmod -R 750 /var/lib/gitea/
mkdir /home/gitea
chown gitea:gitea /home/gitea
mkdir /etc/gitea
chown root:gitea /etc/gitea
chmod 770 /etc/gitea
-
指定gitea保存数据目录
export GITEA_WORK_DIR=/var/lib/gitea/
-
配置gitea开机自启
wget https://raw.githubusercontent.com/go-gitea/gitea/master/contrib/systemd/gitea.service
# 修改
User=gitea
Group=gitea
Environment=USER=gitea HOME=/home/gitea
cp gitea.service /etc/systemd/system/
systemctl enable gitea
systemctl start gitea
安装Gitea
两处改为gitea主机IP或域名 登陆成功启用https
-
创建密钥
gitea cert --host 192.0.2.10
cp cert.pem /var/lib/gitea/ssl
cp key.pem /var/lib/gitea/ssl
-
修改/etc/gitea/app.ini
# 添加或修改以下字段
[server]
PROTOCOL = https
ROOT_URL = https://git.example.com:3000/
HTTP_PORT = 3000
CERT_FILE = /var/lib/gitea/cert.pem
KEY_FILE = /var/lib/gitea/key.pem
REDIRECT_OTHER_PORT = true
; Port the redirection service should listen on
PORT_TO_REDIRECT = 3080 # 3080是gitea的默认https端口
systemctl restart gitea
网友评论