首頁>技術>

Gitea 是使用 Go 語言開發的類 GitHu 和 GitLab 的 Git 程式碼託管工具,使用 Go 語言編寫,具有速度快、資源消耗小和維護活躍的特點。

本文資料是我的以下視訊的補充材料:

Gitea 安裝配置

1. Linux 環境配置

新增一個名為 `git` 的系統賬號用於 Gitea 的執行:

# adduser --system --group git

建立 Gitea 的工作目錄:

$sudo mkdir /var/lib/gitea$sudo chown git:git /var/lib/gitea

下載 gitea

以 1.8.1 版本為例:

$ cd /tmp$ wget axel https://dl.gitea.io/gitea/1.8.1/gitea-1.8.1-linux-amd64

建立 `/opt/gitea` 目錄並移動 Gitea 的可執行檔案進去:

$ sudo mkdir /opt/gitea$ sudo mv /tmp/gitea-1.8.1-linux-amd64 /opt/gitea/gitea

增加執行許可權

$sudo chmod a+x /opt/gitea/gitea

下載 Gitea 的 Systemd 服務配置檔案:

$cd /tmp$wget https://raw.githubusercontent.com/go-gitea/gitea/master/contrib/systemd/gitea.service

用編輯器開啟 /tmp/gitea.service 檔案修改相應的資料庫、路徑及使用者資訊:

[Unit]Description=Gitea (Git with a cup of tea)After=syslog.targetAfter=network.target#Requires=mysql.service#Requires=mariadb.service# 我們這裡使用 PostgreSQLRequires=postgresql.service#Requires=memcached.service#Requires=redis.service[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=65535RestartSec=2sType=simpleUser=gitGroup=gitWorkingDirectory=/var/lib/gitea/ExecStart=/usr/local/bin/gitea web -c /home/git/etc/gitea.iniRestart=alwaysEnvironment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea# If you want to bind Gitea to a port below 1024 uncomment# the two values below####CapabilityBoundingSet=CAP_NET_BIND_SERVICE#AmbientCapabilities=CAP_NET_BIND_SERVICE[Install]WantedBy=multi-user.target

複製 `gitea.service` 進入 SystemD:

$sudo cp /tmp/gitea.service /etc/systemd/system
2. 資料庫配置

這裡我們採用 PostgreSQL 資料庫,為 Gitea 建立使用者名稱及密碼都為 `gitea` 的資料庫角色及空庫:

$sudo su - postgrespsql -c "CREATE ROLE gitea WITH PASSWORD 'gitea' LOGIN CREATEDB"psql -c "CREATE DATABASE gitea_db OWNER gitea ENCODING 'UTF8'"
啟動 Gitea
$sudo systemctl enable gitea$sudo systemctl start gitea

到這裡,用瀏覽器開啟預設的 http://localhost:3000 即可看到 Gitea 的頁面,說明我們的配置就成功了。

最新評論
  • BSA-TRITC(10mg/ml) TRITC-BSA 牛血清白蛋白改性標記羅丹明
  • Android App滲透測試--Drozer(安裝篇)