Ubuntu 20.04 + Gerrit 3.4.0 + nginx 1.18.0 安裝配置指南

           Ubuntu 20.04 + Gerrit 3.4.0 + nginx 1.18.0 安裝配置指南

1、前言

2020/09/22 15:10   本人發佈過一篇 ” Ubuntu 18.04+Postgresql 10+Gerrit 2.15.19+nginx 1.14 “ 安裝配置指南,原文鏈接如下:

Ubuntu 18.04+Postgresql 10+Gerrit 2.15.19+nginx 1.14     閱讀數 1.4K ,快一年時間了,各系統也都升級了,今天繼續分享新版本的安裝配置。

2、系統平臺

  • 操作系統:Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-77-generic x86_64
  • 數據庫NoteDb 是 Gerrit 3.0+ 支持的唯一數據庫格式     
  • 官方介紹如下
  • 代碼審查系統Gerrit 3.4.0
  • Web 服務器:nginx version: nginx/1.18.0 (Ubuntu)  高性能的 HTTP 和反向代理 Web 服務器
  • 瀏覽器訪問

3、安裝配置

首先要執行一下系統更新,執行如下兩條指令:

$ sudo apt-get update
$ sudo apt-get -y upgrade
 
一、安裝 JDK 11 官方說明如下:
 
Gerrit 的 Java 語言級別現在默認設置爲 Java 11
下載好  jdk-11.0.10_linux-x64_bin.tar.gz 版本安裝,配置好環境變量,顯示如下:
 
二、安裝 gerrit
下載最新版本 3.4.0
 
初始化安裝,執行下面的安裝指令:
java -jar gerrit-3.4.0.war init -d /home/scm/review_site
 
 
安裝過程中的詳細參數配置選項如下:

scm@scm:~$ java -jar gerrit-3.4.0.war init -d /home/scm/review_site
Using secure store: com.google.gerrit.server.securestore.DefaultSecureStore
[2021-07-20 08:25:51,417] [main] INFO  com.google.gerrit.server.config.GerritServerConfigProvider : No /home/scm/review_site/etc/gerrit.config; as                      suming defaults

*** Gerrit Code Review 3.4.0
***

Create '/home/scm/review_site' [Y/n]? Y

*** Git Repositories
***

Location of Git repositories   [git]: git

*** JGit Configuration
***

Auto-configured "receive.autogc = false" to disable auto-gc after git-receive-pack.

*** Index
***

Type                           [lucene]:

*** User Authentication
***

Authentication method          [openid/?]: http
Get username from custom HTTP header [y/N]? n
SSO logout URL                 :
Enable signed push support     [y/N]?

*** Review Labels
***

Install Verified label         [y/N]? y

*** Email Delivery
***

SMTP server hostname           [localhost]:
SMTP server port               [(default)]:
SMTP encryption                [none/?]:
SMTP username                  :

*** Container Process
***

Run as                         [scm]:
Java runtime                   [/usr/local/jdk-11.0.10]:
Copy gerrit-3.4.0.war to /home/scm/review_site/bin/gerrit.war [Y/n]? Y
Copying gerrit-3.4.0.war to /home/scm/review_site/bin/gerrit.war

*** SSH Daemon
***

Listen on address              [*]:
Listen on port                 [29418]:
Generating SSH host key ... rsa... ed25519... ecdsa 256... ecdsa 384... ecdsa 521... done

*** HTTP Daemon
***

Behind reverse proxy           [y/N]? y
Proxy uses SSL (https://)      [y/N]?
Subdirectory on proxy server   [/]:
Listen on address              [*]:
Listen on port                 [8081]:
Canonical URL                  [http://scm/]: http://192.168.23.134

*** Cache
***


*** Plugins
***

Installing plugins.
Install plugin codemirror-editor version v3.4.0 [y/N]? y
Installed codemirror-editor v3.4.0
Install plugin commit-message-length-validator version v3.4.0 [y/N]? y
Installed commit-message-length-validator v3.4.0
Install plugin delete-project version v3.4.0 [y/N]? y
Installed delete-project v3.4.0
Install plugin download-commands version v3.4.0 [y/N]? y
Installed download-commands v3.4.0
Install plugin gitiles version v3.4.0 [y/N]? y
Installed gitiles v3.4.0
Install plugin hooks version v3.4.0 [y/N]? y
Installed hooks v3.4.0
Install plugin plugin-manager version v3.4.0 [y/N]? y
Installed plugin-manager v3.4.0
Install plugin replication version v3.4.0 [y/N]? y
Installed replication v3.4.0
Install plugin reviewnotes version v3.4.0 [y/N]? y
Installed reviewnotes v3.4.0
Install plugin singleusergroup version v3.4.0 [y/N]? y
Installed singleusergroup v3.4.0
Install plugin webhooks version v3.4.0 [y/N]? y
Installed webhooks v3.4.0
Initializing plugins.

============================================================================
Welcome to the Gerrit community

Find more information on the homepage: https://www.gerritcodereview.com
Discuss Gerrit on the mailing list: https://groups.google.com/g/repo-discuss
============================================================================
Initialized /home/scm/review_site
Init complete, reindexing accounts with: reindex --site-path /home/scm/review_site --threads 1 --index accountsReindexed 0 documents in accounts i                      ndex in 0.0s (0.0/s)
Index accounts in version 11 is ready
Collecting projects:    2 changes with: reindex --site-path /home/scm/review_site --threads 1 --index changes
Reindexing changes: project-slices: 100% (2/2), done
Reindexed 0 documents in changes index in 0.0s (0.0/s)
Index changes in version 61 is ready
Reindexing groups:      100% (2/2)ith: reindex --site-path /home/scm/review_site --threads 1 --index groups
Reindexed 2 documents in groups index in 0.2s (10.2/s)
Index groups in version 8 is ready
Reindexing projects:    100% (2/2) with: reindex --site-path /home/scm/review_site --threads 1 --index projects
Reindexed 2 documents in projects index in 0.1s (13.4/s)
Index projects in version 4 is ready

 
安裝完成後,進入安裝主目錄,顯示如下:
此時就可以執行啓動 gerrit 系統了,到bin目錄下執行。
顯示 OK ,說明 gerrit 啓動正常,打開瀏覽器訪問 gerrit 系統。
瀏覽器頁面顯示 Check the HTTP server's authentication settings.   說明代理配置有問題,接着配置代理服務器。
三、安裝nginx
sudo apt -y install nginx
 
安裝完成,查看安裝的版本信息。
 
 
下面進行 nginx 服務的配置。
 
進入到 sites-enabled 目錄,修改  default  文件,顯示如下:
vim 修改,如下圖所示,綠框修改模板。
 
修改部分代碼如下:
location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                #try_files $uri $uri/ =404;
                auth_basic              "GerritCodeReview";
                auth_basic_user_file    /home/scm/review_site/etc/passwords;
                proxy_pass              http://192.168.23.134:8081/;
                proxy_set_header        X-Forwarded-For $remote_addr;
                proxy_set_header        Host $host;
        }
 
修改好保存退出,然後重新啓動  nginx 服務,啓動顯示如下:
 
 
此時,重新打開瀏覽器訪問 gerrit 系統,提示輸入用戶名、密碼,輸入正確的賬戶就能登錄了。
 
輸入用戶名、密碼登錄系統,顯示如下:
 
 
顯示登錄系統的用戶名,顯示版本信息。
 
 
 
 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章