前面介绍过 ubuntu 环境下 gerrit 代码审查服务器的安装,现在需要在 redhat 环境下也要搭建一套,具体的过程备案如下。
$ sudo yum install jre
$ sudo yum install httpd
$ sudo yum install gcc-c++
$ 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
$ 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
$ 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
$ 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 <[email protected]> [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
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
登陆 http://192.168.13.202/gerrit/login
$ 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
$ tail gerrit.config [httpd] listenUrl = proxy-http://*:8081/gerrit [cache] directory = cache [gitweb] cgi = /usr/lib/cgi-bin/gitweb.cgi
gitweb 需要能够访问 refs/meta/config ,为此需要修改 All-Projects 项目,增加 Registered Users 对 refs/meta/config 的 read 访问权限。
$ htpasswd /home/gerrit/review_site/etc/gerrit.passwd isxxguo
第一次进入会提示完善账号信息,并且添加 SSH KEY
$ cat ~/.ssh/config host ppboxrom user isxxguo hostname 192.168.13.202 port 29418 identityfile ~/.ssh/id_rsa
$ chmod 600 ~/.ssh/config