[gerrit] basePath = /home/gerrit/GerritResource -->第5点创建的空目录 canonicalWebUrl = http://10.10.90.160:8081/ [database] type = H2 -->使用默认的H2数据库 database = db/ReviewDB [auth] type = HTTP [sendemail] enable = true smtpServer = smtp.163.com smtpUser = abc@163.com -->gerrit服务器用于发送邮件的邮箱 smtpPass = email-passwd -->邮箱密码 from = abc@163.com -->邮件中显示的发件人 [container] user = gerrit javaHome = /opt/jdk1.6.0_38/jre [sshd] listenAddress = *:29418 [httpd] listenUrl = proxy-http://10.10.90.160:8081/ [cache] directory = cache
7、安装apache2服务器
sudo apt-get install --reinstall apache2 apache2.2-common
8、配置apache2服务器
8.1、开启代理功能、复写功能(以下模块链接到mods-available)
cd /etc/apache2/mods-enabled
ln -s ../mods-available/proxy.load
ln -s ../mods-available/proxy.conf
ln -s ../mods-available/proxy_http.load
ln -s ../mods-available/proxy_balancer.conf
ln -s ../mods-available/proxy_balancer.load
ln -s ../mods-available/rewrite.load
ln -s ../mods-available/ssl.conf
ln -s ../mods-available/ssl.load
8.2、配置apache2的监听端口
$: vi /etc/apache2/ports.conf
……
NameVirtualHost *:80
NameVirtualHost *:8080 -->仿照80端口,加上对8080端口的监听。
Listen 80
Listen 8080
……
8.3、配置反向代理
$: sudo vi /etc/apache2/httpd.conf
ServerName ganshuyu.test.com <VirtualHost *:8081> ServerName ganshuyu.pbi.com <VirtualHost *:8080> -->客户端访问:http:10.10.90.160:8081 会转到gerrit服务器的地址:http://10.10.90.160:8080 上 ProxyRequests Off ProxyVia Off ProxyPreserveHost On AllowEncodedSlashes NoDecode RewriteEngine On RewriteRule ^/(.*) http://10.10.90.160:8081/$1 [NE,P] <Proxy *> Order deny,allow Allow from all </Proxy> <Location /login/> AuthType Basic AuthName "Gerrit Code Review" Require valid-user AuthBasicProvider file AuthUserFile /home/gerrit/review_site/etc/passwd </Location> ProxyPass / http://10.10.90.160:8081/ </VirtualHost>
8.4、主配置文件中加入httpd.conf,使其生效
$: sudo vi /etc/apache2/apache2.conf
查看是否已包含:httpd.conf,如果没有,则加上如下这句话:
Include httpd.conf
9、设置第一个gerrit用户的账号和密码
$: touch ./review_site/etc/passwd
$: htpasswd -b ./review_site/etc/passwd gerritUser1 123456789
(后续再添加gerrit用户可使用: $: htpasswd -b ./review_site/etc/passwd UserName PassWord )
10、开启gerrit服务器
$: ./review_site/bin/gerrit.sh start
如果提示发生如下错误:
** ERROR: GERRIT_SITE not set
则可按如下方法修改:
$: vim gerrit.sh
在GERRIT_SITE变量被赋值之后加入下面这行,改变该变量的值。
GERRIT_SITE=/home/gerrit/review_site
11、重启apache2服务器
$: sudo /etc/init.d/apache2 restart
12、访问: http://10.10.90.160:8080/ ,用gerritUser1用户登录:
联系客服