軟件環境配置
安裝Jdk: apt-get install openjdk-8-jre
安裝Apache: apt-get install apache2
安裝Git: apt-get git
Apache配置反向代理
修改文件 vi /etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
ServerName 192.168.1.10
ProxyRequests Off
ProxyVia Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location "/login/">
AuthType Basic
AuthName "Gerrit Code Review"
Require valid-user
AuthBasicProvider file
AuthUserFile /home/gerrit/passwords
</Location>
AllowEncodedSlashes On
ProxyPass / http://192.168.1.10:8081/
</VirtualHost>
Apache配置 開啟SSL、Proxy、Rewrite等模塊
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
ln -s ../mods-available/slotmem_shm.load
ln -s ../mods-available/socache_shmcb.load
創建用戶數據文件
htpasswd -cb /home/gerrit/passwords admin admin #創建首次登陸管理員用戶
htpasswd -b /etc/httpd/passwords test test #創建其他用戶
在gerrit安裝目錄 /home/gerrit
java -jar gerrit-3.0.3.war init
gerrit下載地址:https://gerrit-releases.storage.googleapis.com/gerrit-3.0.3.war
重要設置
Authentication method [openid/?]: HTTP
Behind reverse proxy [y/N]? y
Listen on port [8081]:
Canonical URL http://192.168.1.10:8081/
啟動gerrit
/home/gerrit/bin/gerrit.sh start