代码审查服务gerrit搭建+httpd反向代理

一、安装依赖:

安装java8依赖

[root@localhost ~]# yum install java-1.8.0-openjdk* -y

安装git依赖

[root@localhost ~]# yum install git

二、安装httpd反向代理

[root@localhost ~]# yum install httpd

三、搭建gerrit

1.创建gerrit用户

[root@localhost ~]# adduser gerrit

2.切换到gerrit用户中

[root@localhost ~]# su gerrit

3.下载安装包

在该链接下载到本地。https://gerrit-releases.storage.googleapis.com/index.html 

博主下的gerrit版本是2.13.4版本的。利用xftp上传gerrit安装包gerrit-2.13.4.war到/home/gerrit目录下

 

4.切换回root用户,输入密码

[gerrit@localhost ~]# su root

5.进入到/home/gerrit目录下

[root@localhost ~]# cd /home/gerrit

6.查看是否有gerrit-2.13.4.war安装包

[root@localhost ~]# ls

7.有安装包的话,进行安装,安装过程会让你选择,只是在让你选择Authentication method方式时输入http。其他的默认回车就好 。安装命令如下

[root@localhost gerrit]# java -jar gerrit-2.13.4.war init -d /home/gerrit/gerrit_site

当下载过程中,出现这句话的时候说明再下载东西,别着急,等一会,时间会长些

Downloading http://www.bouncycastle.org/download/bcpkix-jdk15on-151.jar ...

会下载如下两个文件,大概不到3M,有时候下载会中断或者失败,可以查看/home/gerrit/gerrit_site/lib目录下的两个文件,如果文件大小接近3M,那说明下载成功,如果差距很大,那就删除gerrit_site文件,重新安装。博主安装整个流程不下5次,知道这里有时候失败次数会较多,不要放弃,重启虚拟机再试,总有一次会成功的。

 

8.关闭防火墙或者给防火墙开启指定8080端口号,我为了省事直接关闭了防火墙

[root@localhost etc]# systemctl stop firewalld

9.打开自己浏览器输入虚拟机的ip地址后面跟:8080端口号,出现这个界面表示前面gerrit搭建的步骤是成功的

10.进入/etc/httpd/conf.d路径下

[root@localhost etc]# cd /etc/httpd/conf.d

11.创建配置文件gerrit.conf,httpd根据这个文件进行路由跳转,反向代理

[root@localhost conf.d]# touch gerrit.conf

12.修改配置文件

[root@localhost conf.d]# vi gerrit.conf

配置文件内容如下。将xxx改成自己的ip地址

ServerName xxx.xxx.xxx.xxx
<VirtualHost *:80>
    ProxyRequests Off
    ProxyVia Off
    ProxyPreserveHost On
    AllowEncodedSlashes On
 
    <Proxy *>
          Order deny,allow
          Allow from all
    </Proxy>
 
    <Location /login/>
        AuthType Basic
        AuthName "Gerrit Code Review"
        Require valid-user
        AuthBasicProvider file
        AuthUserFile /etc/httpd/conf.d/gerritpw
    </Location>
    ProxyPass / http://xxx.xxx.xxx.xxx:8080/ 
</VirtualHost>

14.创建配置文件,用户根据这个文件中的用户密码限制登陆

[root@localhost conf.d]# touch gerritpw

15.在该路径下输入命令,创建登录用户

[root@localhost conf.d]# htpasswd -b /etc/httpd/conf.d/gerritpw admin 123456

16.重启httpd

[root@localhost conf.d]# systemctl restart httpd

17.打开自己浏览器输入虚拟机的ip地址,直接回车。出现503错误,这是正常现象

18.输入下面命令

[root@localhost conf.d]# /usr/sbin/setsebool httpd_can_network_connect 1

最后刷新页面,输入账号admin密码123456即可成功,第一次进入显示无页面,在输入ip地址刷新下页面就成功了

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章