Background

  1. 需要托管一些自己的代码
  2. 这些代码可能要吃DMCA
  3. GitHub 无预警突然封号 - V2EX Github的连坐机制
  4. 就是想折腾

Steps

Install Git(Version >= 2.0)

Cent OS 7 Example

Add wandisco-git Repo
vim /etc/yum.repos.d/wandisco-git.repo

[wandisco-git]
name=Wandisco GIT Repository
baseurl=http://opensource.wandisco.com/centos/7/git/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://opensource.wandisco.com/RPM-GPG-KEY-WANdisco

Import repo GPG Key
rpm --import http://opensource.wandisco.com/RPM-GPG-KEY-WANdisco
Install latest version of git
yum install git

Download

wget -O gitea https://dl.gitea.io/gitea/1.16.4/gitea-1.16.4-linux-amd64``

Verify

gpg --keyserver keys.openpgp.org --recv 7C9E68152594688862D62AF62D9AE806EC1592E2
gpg --verify gitea-1.16.4-linux-amd64.asc gitea-1.16.4-linux-amd64

Preper Directory

mkdir -p /opt/gitea/{custom,data,log}
chown -R git:git /opt/gitea/
chmod -R 750 /opt/gitea/
mkdir /opt/gitea/config
chown root:git /opt/gitea/config
chmod 770 /opt/gitea/config
chmod 750 /opt/gitea/config
chmod 640 /opt/gitea/config/app.ini
mv gitea /opt/gitea/

Create Git user

adduser \
   --system \
   --shell /bin/bash \
   --gecos 'Git Version Control' \
   --group \
   --disabled-password \
   --home /home/git \
   git

Install and Run

su git && GITEA_WORK_DIR=/opt/gitea/ /opt/gitea/gitea web -c /opt/gitea/config/app.ini

Mod the config

修改此处配置文件/opt/gitea/config/app.ini

# 并不想让用户注册
[service]
REGISTER_EMAIL_CONFIRM            = false
ENABLE_NOTIFY_MAIL                = false
DISABLE_REGISTRATION              = true
ALLOW_ONLY_EXTERNAL_REGISTRATION  = false
ENABLE_CAPTCHA                    = false
REQUIRE_SIGNIN_VIEW               = false
DEFAULT_KEEP_EMAIL_PRIVATE        = false
DEFAULT_ALLOW_CREATE_ORGANIZATION = true
DEFAULT_ENABLE_TIMETRACKING       = true
NO_REPLY_ADDRESS                  = noreply.localhost

# 并不想启动OPENID,目前用不到
[openid]
ENABLE_OPENID_SIGNIN = false
ENABLE_OPENID_SIGNUP = false

Run with pm2

创建 start.sh

#!/bin/bash
GITEA_WORK_DIR=/opt/gitea/ /opt/gitea/gitea web -c /opt/gitea/config/app.ini

使用git用户启动

sudo -u git pm2 start start.sh