平台:Ubuntu
需要JDK环境,下载gerrit放根目录
安装,全部默认
java -jar gerrit-2.13.6.war init -d review_site
建立git仓库
mkdir /home/gerrit/repositories
nano review_site/etc/gerrit.config
修改如下
[gerrit] basePath = /home/gerrit/repositories serverId = 8c30499b-3156-4992-8254-a905239811b5 canonicalWebUrl = http://192.168.137.6:8888/ [database] type = h2 database = /home/gerrit/review_site/db/ReviewDB [auth] type = HTTP [receive] enableSignedPush = false [sendemail] smtpServer = smtp.exmail.qq.com smtpServerPort = 465 smtpEncryption = SSL smtpUser = ming.yang@yidatec.com smtpPass = !QAZ2wsx from = ming.yang@yidatec.com [container] user = gerrit javaHome = /opt/jdk1.8.0_121/jre [sshd] listenAddress = *:29418 [httpd] listenUrl = http://192.168.137.6:8888/ [cache] directory = cache
安装apache2
sudo apt install apache2
修改配置
sudo nano /etc/apache2/ports.conf
新增9999端口
. . . . . . Listen 80 Listen 9999 . . . . . .
配置反向代理
sudo nano /etc/apache2/httpd.conf
ServerName gerrit.com
<VirtualHost *:9999>
ProxyRequests Off
ProxyVia Off
ProxyPreserveHost On
AllowEncodedSlashes On
RewriteEngine On
RewriteRule ^/(.*) http://192.168.137.6:8888/$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://192.168.137.6:8888/
</VirtualHost>
主配置文件中加入httpd.conf,使其生效
sudo nano /etc/apache2/apache2.conf
加一句
Include httpd.conf
touch ./review_site/etc/passwd
htpasswd -b ./review_site/etc/passwd admin 123
开启一些模块
sudo a2enmod proxy
sudo a2enmod rewrite
sudo a2enmod ssl
sudo a2enmod proxy_balancer
sudo a2enmod proxy_http
关掉gerrit服务
./review_site/bin/gerrit.sh stop
清空数据库
cd review_site/bin/
java -jar ./gerrit.war gsql -d ../
DROP ALL OBJECTS;
不这样做会有Server Error,Missing project All-Projects的错误
java.lang.IllegalStateException: Missing project All-Projects
重新安装一遍gerrit
java -jar gerrit-2.13.6.war init -d review_site
启动服务
./review_site/bin/gerrit.sh start sudo /etc/init.d/apache2 restart
客户端可通过http://192.168.137.6:9999访问啦