Bootstrap

群晖搭建Gitea教程(使用系统自带的postgresql)

基于群晖7.2.2,使用套件中心的gitea,和系统自带的postgresql

postgresql:

切换到postgres用户

sudo -I -u postgres

在想要保存数据库的磁盘路径下创建PostgreSql文件夹

初始化数据库文件夹配置

initdb -D ./PostgreSql

备份./PostgreSql路径下的postgresql.conf / pg_hba.conf / pg_ident.conf 等文件

cp postgresql.conf postgresql.conf.bak

cp pg_hba.conf pg_hba.conf.bak

cp pg_ident.conf pg_ident.conf.bak

拷贝系统postgresql默认配置文件到当前目录

cp /etc/postgresql/postgresql.conf ./

cp /etc/postgresql/pg_hba.conf ./

cp /etc/postgresql/pg_ident.conf ./

修改postgresql.conf中port为5433(如果没有则新增),以及hba_file和ident_file为PostgreSql路径下的配置文件,并屏蔽external_pid_file和include_if_exists

port = 5433

hba_file = '/xxx/PostgreSql/pg_hba.conf'

ident_file = '/xxx/PostgreSql/pg_ident.conf'

修改pg_hba.conf允许gitea远程使用gitea账号连接gitearepos数据库,以及允许本机不使用gitearepos账号免密连接gitearepos

# TYPE DATABASE       USER           ADDRESS                METHOD

local  all            postgres                               peer map=pg_root

local  all            all                                    peer

host   postgres       postgres      127.0.0.1/32            trust

host   gitearepos     gitea         127.0.0.1/32            md5

使用postgres账号连接到新建立的实例

psql -h localhost -p 5433 -U gitearepos -d gitearepos

在sql命令行中输入如下命令创建gitea账户和数据库gitearepos

CREATE USER gitea WITH PASSWORD 'your password';

CREATE DATABASE gitearepos OWNER gitea;

创建开机启动脚本.startup.sh并输入如下内容

#!/bin/bash

sudo -u postgres PGDATA=/volume2/PostgreSql postgres -D /volume2/PostgreSql

使用计划任务并以root用户执行.startup.sh

gitea:

在套件中心搜索gitea并安装

重启

打开gitea web使用postgresql数据库连接刚刚创建的postgresql实例和数据库

主机填:127.0.0.1

端口号则为第二个新建的postgresql的实例端口号:5433

账户名和密码、数据库都是在新建的postgresql实例中所创建的

gitea登录成功后使用编辑器编辑gitea配置文件/volume1/@appdata/gitea/conf.ini,打开gitea内置ssh服务,并修改端口号(注意端口号需要大于1024,不然没有权限)

START_SSH_SERVER = true

SSH_PORT = 8419

重启即可使用ssh拉取仓库了

;