CentOS下Gerrit部署

参考文档:https://www.cnblogs.com/yinzhengjie/p/11007383.html

1、JDK环境部署

  • 解压jdk-8u231-linux-x64.tar.gz到/home/opt/jdk下
  • 将jdk路径配置到系统路径下
    • sudo vim /etc/profile
    • # add jdk path
    • export JAVA_HOME=/home/opt/jdk/jdk1.8.0_231
    • export PATH=$JAVA_HOME/bin:$PATH
  • 退出当前终端后重新打开终端

2、Git环境部署

  • 卸载原有的Git
    • sudo yum -y remove git
  • 安装Git
    • sudo yum install -y gitweb
    • sudo yum -y install epel-release
    • sudo yum install -y git-review
    • sudo yum -y install wget
    • wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.12.2.tar.gz
    • sudo yum install -y curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker
    • mkdir -p /home/opt/git; tar -xvf git-2.12.2.tar.gz; cd git-2.12.2; sudo su
    • ./configure prefix=/home/opt/git/git-2.12.2
    • make && make install
  • 将Git路径配置到系统路径下
    • sudo vim /etc/profile
    • # add git path
    • export GIT_HOME=/home/opt/git/git-2.12.2
    • export PATH=$GIT_HOME/bin:$PATH
  • 退出当前终端后重新打开终端
  • 配置Git
    • git config --global user.name "wenfei6316"
    • git config --global user.email "[email protected]"
    • git config --global color.ui true

3、Apache服务器部署

  • sudo yum -y install httpd
  • sudo systemctl start httpd
  • sudo systemctl enable httpd
  • sudo systemctl status httpd

4、Gerrit环境部署

  • 下载gerrit-3.0.0.war
  • 创建gerrit用户
    • sudo useradd gerrit
    • sudo passwd gerrit
    • sudo vim /etc/sudoers
    • 102 行添加:gerrit  ALL=(ALL)       ALL
  • 安装gerrit
    • java -jar gerrit-3.0.0.war init -d review_site
    • 每一步的设置配置
      • Create '/home/gerrit/review_site' [Y/n]? Y
      • Location of Git repositories   [git]:
      • Type                           [lucene/?]:
      • Authentication method          [openid/?]: http
      • Get username from custom HTTP header [y/N]?
      • SSO logout URL                 :
      • Enable signed push support     [y/N]?
      • Install Verified label         [y/N]?
      • SMTP server hostname           [localhost]:
      • SMTP server port               [(default)]:
      • SMTP encryption                [none/?]:
      • SMTP username                  :
      • Run as                         [gerrit]:
      • Java runtime                   [/home/opt/jdk1.8.0_231/jre]:/home/opt/jdk/jdk1.8.0_231/jre
      • Listen on address              [*]:
      • Listen on port                 [29418]:
      • Behind reverse proxy           [y/N]?
      • Use SSL (https://)             [y/N]?
      • Listen on address              [*]:
      • Listen on port                 [8080]:
      • Canonical URL                  [http://localhost:8080/]:
      • 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]?
    • 配置结束出现:

CentOS下Gerrit部署_第1张图片

 

  • 创建gerrit用户
    • sudo htpasswd -cb /etc/httpd/passwords admin admin
    • sudo htpasswd -b /etc/httpd/passwords wenfei wenfei6316
  • 设置Apache的反向代理
    • vim /etc/httpd/conf/httpd.conf

Listen 9090

    ServerName 192.168.0.103

    ProxyRequests Off

    ProxyVia Off

    ProxyPreserveHost On

   

        Order deny,allow

        Allow from all

   

   

        AuthType Basic

        AuthName "Gerrit Code Review"

        Require valid-user

        AuthUserFile /etc/httpd/passwords

   

    AllowEncodedSlashes On

    ProxyPass / http://192.168.0.103:8080/

  • sudo systemctl restart httpd
  • 登陆gerrit

打开firefox输入网址:http://localhost:9090或http://192.168.0.103:9090出现以下表示部署成功

CentOS下Gerrit部署_第2张图片

 

问题解决:

1、打开网页出现如下时解决办法

CentOS下Gerrit部署_第3张图片

解答方法:gerrit需要使用反响代理,执行创建gerrit用户和设置Apache的反向代理即可

2、执行sudo systemctl restart httpd出现如下

解答方法:

执行sudo systemctl status httpd出现

CentOS下Gerrit部署_第4张图片

执行sudo setenforce 0

执行sudo systemctl start httpd和sudo systemctl status httpd均OK

参考https://blog.csdn.net/weixin_43557605/article/details/99289599

你可能感兴趣的:(工具)