Quantcast
Channel: 簡睿隨筆
Viewing all articles
Browse latest Browse all 897

[Windows] 用Gitea架設自用的Git Server

$
0
0

Gogs是一套架設在Windows下的Git Server軟體,使用Go語言撰寫(Gogs正是Go Git Service的縮寫),由對岸網友開發,後來因為社群對其管理模式有疑慮,而分支出另一個Gitea: Git with a cup of tea,本文便是在安裝與設定Gitea的一些備忘紀錄。

原本我一直使用Gogs在測試,最後在要安裝成Windows服務時卻始終無法成功,轉而用Gitea試,終於安裝成功,因而就轉換使用Gitea了。

Gitea的安裝

首先到下載網頁下載最後的穩定版(此時下載的是gitea-1.1.2-windows-4.0-amd64.exe),並存到特定目錄(如D:\gitea),再把執行檔改名為gitea.exe。執行gitea.exe後會顯示能使用的選項:

d:\gitea> gitea.exe NAME: Gitea - A painless self-hosted Git service

USAGE: gitea.exe [global options] command [command options] [arguments...]

VERSION: 1.1.2 built with: bindata, sqlite

COMMANDS: web Start Gitea web server serv This command should only be called by SSH shell hook Delegate commands to corresponding Git hooks dump Dump Gitea files and database cert Generate self-signed certificate admin Perform admin operations on command line help, h Shows a list of commands or help for one command

GLOBAL OPTIONS: --help, -h show help --version, -v print the version

只要用gitea web就能啟用Git server。

d:\gitea> gitea web
2017/06/29 22:43:42 [W] Custom config 'd:/gitea/custom/conf/app.ini' not found, ignore this if you're running first time
2017/06/29 22:43:42 [T] Custom path: d:/gitea/custom
2017/06/29 22:43:42 [T] Log path: d:/gitea/log
2017/06/29 22:43:42 [I] Gitea v1.1.2 built with: bindata, sqlite
2017/06/29 22:43:42 [I] Log Mode: Console(Trace)
2017/06/29 22:43:42 [I] XORM Log Mode: Console(Trace)
2017/06/29 22:43:42 [I] Cache Service Enabled
2017/06/29 22:43:42 [I] Session Service Enabled
2017/06/29 22:43:42 [I] SQLite3 Supported
2017/06/29 22:43:42 [I] Run Mode: Development
2017/06/29 22:43:42 [I] Listen: http://0.0.0.0:3000`

設定檔 app.ini

啟動後第一行就有設定檔的完整路徑:d:\gitea\custom\conf\app.ini。在更新新版時不會覆蓋custom資料夾,因此能保存原有的設定。第一次執行時不會自動產生app.ini,由瀏覽器瀏覽 http://localhost:3000/install 完成安裝程序後才會寫出app.ini。

在安裝網頁裡逐一填入各項設定值即可,資料庫使用SQLite時要注意一點:資料庫檔名必須用完整路徑(如D:\gitea\data\gitea.db),若使用 data/gitea.db 且於服務裡啟動,則資料庫會跑到 C:\Windows\system32\data\gitea.db。

install

以下是我的app.ini設定:

APP_NAME = Gitea: Git with a cup of tea
RUN_USER = Administrator
RUN_MODE = prod

[database]
DB_TYPE  = sqlite3
HOST     = 127.0.0.1:3306
NAME     = gitea
USER     = gitea
PASSWD   = 
SSL_MODE = disable
PATH     = c:/gitea/data/gitea.db

[repository]
ROOT = c:/git-repo2

[server]
PROTOCOL = https
DOMAIN           = git.??????.com.tw
HTTP_PORT        = 443
ROOT_URL         = https: //git.??????.com.tw/
DISABLE_SSH      = true
SSH_PORT         = 22
LFS_START_SERVER = false
OFFLINE_MODE     = false
CERT_FILE = C:/gitea/custom/https/cert.pem
KEY_FILE = C:/gitea/custom/https/key.pem

[mailer]
ENABLED = true
HOST    = ??????.com.tw:25
FROM    = ??????@??????.com.tw
USER    = ??????
PASSWD  = ??????

[service]
REGISTER_EMAIL_CONFIRM     = true
ENABLE_NOTIFY_MAIL         = true
DISABLE_REGISTRATION       = false
ENABLE_CAPTCHA             = false
REQUIRE_SIGNIN_VIEW        = false
DEFAULT_KEEP_EMAIL_PRIVATE = false
NO_REPLY_ADDRESS           = noreply.example.org

[picture]
DISABLE_GRAVATAR        = false
ENABLE_FEDERATED_AVATAR = false

[session]
PROVIDER = file

[log]
MODE      = file
LEVEL     = Info
ROOT_PATH = C:/gitea/logs

[security]
INSTALL_LOCK = true
SECRET_KEY   = nC??????U

授權認證管理:LDAP

在管理面板裡的授權認證管理可以設定帳號的認證方式,認證來源有LDAP、SMTP、PAM、Oauth2等幾種,以下是LDAP設定的範例:

LDAP-1

LDAP-2

相關連結

##


您可能也會有興趣的類似文章


Viewing all articles
Browse latest Browse all 897

Trending Articles