gerrit3.0安装

2021-05-14 17:06:17 浏览数 (1)

gerrit3.0安装

强烈推介IDEA2020.2破解激活,IntelliJ IDEA 注册码,2020.2 IDEA 激活码

本文主要参考如下几篇文章:

https://blog.51cto.com/zengestudy/1771575

https://www.cnblogs.com/jiangzhaowei/p/7918489.html

https://blog.csdn.net/mr_raptor/article/details/76164373

https://blog.csdn.net/handsome_926/article/details/79758449

其中最详细和靠谱的是这篇文章

https://www.tuicool.com/articles/iAFBvu7

好,下面上货。

1、下载安装包可以在官网上下载

https://gerrit-documentation.storage.googleapis.com/Documentation/3.0.0/install.html

2、新建用户

代码语言:javascript复制
新建gerrit用户
sudo adduser gerrit
sudo su gerrit

3、安装

代码语言:javascript复制
[gerrit@VM_32_3_centos bags]$ java -version
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)
[gerrit@VM_32_3_centos bags]$ java -jar gerrit-3.0.0.war init -d /home/gerrit/gerrit
Using secure store: com.google.gerrit.server.securestore.DefaultSecureStore
[2019-07-30 13:51:43,882] [main] INFO  com.google.gerrit.server.config.GerritServerConfigProvider : No /home/gerrit/gerrit/etc/gerrit.config; assuming defaults

*** Gerrit Code Review 3.0.0
***

Create '/home/gerrit/gerrit'   [Y/n]?

*** Git Repositories
***

Location of Git repositories   [git]: /home/gerrit/gerrit_repo

*** Index
***

Type                           [lucene/?]:

*** User Authentication
***

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

*** Review Labels
***

Install Verified label         [y/N]?

*** Email Delivery
***

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

*** Container Process
***

Run as                         [gerrit]:
Java runtime                   [/usr/local/jdk1.8.0_161/jre]:
Copy gerrit-3.0.0.war to /home/gerrit/gerrit/bin/gerrit.war [Y/n]?
Copying gerrit-3.0.0.war to /home/gerrit/gerrit/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]?
Use SSL (https://)             [y/N]?
Listen on address              [*]:
Listen on port                 [8080]: 8787
Canonical URL                  [http://localhost:8787/]:

*** Cache
***


*** Plugins
***

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

 4、等待运行结果:

 5、这个时候看尝试访问8787端口:

6、我通过查看上面的博客发现,是因为gerrit需要使用反向代理,我这里使用的是nginx。

7、为了让反向代理能够有登录的用户名和密码,需要创建用户名和密码,需要使用到工具htpasswd

代码语言:javascript复制
[root@VM_32_3_centos ~]# htpasswd -c /home/gerrit/gerrit/etc/gerrit.password admin
-bash: htpasswd: command not found
[root@VM_32_3_centos ~]# yum -y install httpd-tools

 然后创建admin用户

8、然后配置nginx反向代理:

代码语言:javascript复制
server {
     listen *:81;
     server_name localhost;
     allow   all;
     deny    all;

     auth_basic "Welcomme to Gerrit Code Review Site!";
     auth_basic_user_file /home/gerrit/gerrit/etc/gerrit.password;

     location / {
        proxy_pass  http://127.0.0.1:8787;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $host;
     }
   }

 9、重新加载nginx配置文件 nginx -s reload

10、再次访问安装机器的81端口:

11、原因是nginx不能访问用户gerrit文件夹的内容。所以需要给gerrit文件夹对应755权限

代码语言:javascript复制
chmod 755 /home/gerrit

12、安装成功

0 人点赞