redhat 环境下 gerrit 代码审查服务器的安装

来源:互联网 发布:有淘宝账号就可以贷款 编辑:程序博客网 时间:2024/06/06 18:22

前面介绍过 ubuntu 环境下 gerrit 代码审查服务器的安装,现在需要在 redhat 环境下也要搭建一套,具体的过程备案如下。

1. 环境准备

  • 安装 java 环境
$ sudo yum install jre
  • 安装 apache httpd
$ sudo yum install httpd
  • 安装 g++
后面需要通过源码编译的方式安装 openssl,python,所以需要有 gcc,g++
$ sudo yum install gcc-c++
  • 安装 openssl
python 编译时依赖 openssl ,没有 openssl 也能够编译通过,但是不支持 https 类型的 url,后面 repo init 会有问题
$ wget https://www.openssl.org/source/openssl-1.0.1f.tar.gz --no-check-certificate$ tar -xzvf openssl-1.0.1f.tar.gz$ cd openssl-1.0.1f$ ./config --prefix=/usr shared -fPIC$ make$ sudo make install
  • 安装 python 2.7

redhat 自带的 python 版本是 2.4 ,需要替换为 2.7 版本
$ wget http://www.python.org/ftp/python/2.7.6/Python-2.7.6.tgz$ tar -xzvf Python-2.7.6.tgz$ cd Python-2.7.6$ ./configure --prefix=/usr$ make$ sudo make install

由于 yum 工具依赖原先的 python 4.2, 所以需要修改 /usr/bin/yum 的第一行,如下:

$ head -1 /usr/bin/yum #!/usr/bin/python2.4

2. 安装配置 gerrit

参考 http://gerrit.googlecode.com/svn/documentation/2.2.1/

2.1 安装 gerrit

  • 新建一个专用 linux 账号
$ sudo adduser gerrit$ sudo su gerrit$ cd ~
  •  下载安装包
$ wget http://gerrit-releases.storage.googleapis.com/gerrit-2.8-rc3.war

  • 安装

$ java -jar gerrit-2.8-rc3.war init -d review_site

2.2 配置 gerrit

参考 http://gerrit.googlecode.com/svn/documentation/2.2.1/config-gerrit.html
$ cat review_site/etc/gerrit.config[gerrit]        basePath = git        canonicalWebUrl = http://192.168.27.42:8081/gerrit[database]        type = h2        database = db/ReviewDB[auth]        type = HTTP        #httpHeader = SM_USER[sendemail]        smtpServer = mail.pptv.com        smtpServerPort = 587        smtpEncryption =         smtpUser = cmguo        smtpPass = 123456        sslVerify = false        from = PPBOX ROM GERRIT <ppbox-rom@pptv.com>[container]        user = gerrit        javaHome = /usr/lib/jvm/java-6-sun-1.6.0.26/jre[sshd]        listenAddress = *:29418[httpd]        listenUrl = proxy-http://*:8081/gerrit[cache]        directory = cache

2.3 配置 httpd

  • 配置反向代理和HTTP认证
cat /etc/httpd/conf.d/proxy_gerrit.conf    <Location /gerrit/login/>  AuthType Basic  AuthName "Gerrit Code Review"  AuthUserFile "/etc/httpd/conf/gerrit.passwd"  Order allow,deny  Allow from all  Require valid-user</Location>ProxyPass /gerrit http://localhost:8081/gerrit nocanon
  • 增加管理员账号
$ htpasswd /etc/httpd/conf/gerrit.passwd cmguo

2.4 验证 gerrit 安装

登陆 http://192.168.13.202/gerrit/login

3. 集成 gitweb

  • 安装 gitweb
$ git clone git://git.kernel.org/pub/scm/git/git.git$ cd git/$ make prefix=/usr gitweb$ make gitwebdir=/var/www/cgi-bin prefix=/usr install-gitweb
  • 配置 gitweb
在 gerrit 配置文件添加 gitweb 配置
$ tail gerrit.config [httpd]        listenUrl = proxy-http://*:8081/gerrit[cache]        directory = cache[gitweb]        cgi = /usr/lib/cgi-bin/gitweb.cgi

  • 配置 gerrit 访问权限

gitweb 需要能够访问 refs/meta/config ,为此需要修改 All-Projects 项目,增加 Registered Users 对 refs/meta/config 的 read 访问权限。

4. 添加新用户

3.1 注册账号

  • 注册 gerrit 账号
$ htpasswd /home/gerrit/review_site/etc/gerrit.passwd isxxguo
  • 注册 SSH key
登陆 http://192.168.13.202/gerrit/
按提示输入用户名,密码

第一次进入会提示完善账号信息,并且添加 SSH KEY

3.2 用户本地配置

  • 配置SSH主机别名
$ cat ~/.ssh/confighost ppboxrom        user isxxguo        hostname 192.168.13.202        port 29418        identityfile ~/.ssh/id_rsa

5. Redhat 环境的其他问题

  • ssh_config 文件的访问权限
${HOME}/.ssh/config 文件的访问权限必须设置为只有 owner 用户能够访问
$ chmod 600 ~/.ssh/config
  • crontab 任务执行时的用户环境
crontab 任务执行时,用户环境变量没有定义,比如 ${HOME} 等等


                                             
0 0
原创粉丝点击