apt-get install openjdk-8-jdk git -y
groupadd gerrit2 -g 666
useradd gerrit2 -u 666 -g 666 -s /sbin/nologin -M
mkdir -p /home/gerrit2/gerrit_site
mkdir -p /home/gerrit2/wars
cd /home/gerrit2/wars
wget https://gerrit-releases.storage.googleapis.com/gerrit-3.2.0.war
vim /etc/profile.d/gerrit.sh
export GERRIT_SITE=/home/gerrit2/gerrit_site
##生效
source /etc/profile
java -jar gerrit-3.2.0.war init -d $GERRIT_SITE
##一路回车,然后再改配置
cp $GERRIT_SITE/etc/gerrit.config $GERRIT_SITE/etc/gerrit.config.bak
vim $GERRIT_SITE/etc/gerrit.config
[gerrit]
basePath = git
canonicalWebUrl = http://172.16.3.50:8080/
serverId = b4ceb906-c94a-4049-9d2f-28b2441e2521
[database]
type = h2
database = db/ReviewDB
[auth]
type = HTTP
[sendemail]
enable = true
smtpServer = smtp.qq.com
smtpServerPort = 465
smtpEncryption = SSL
sslVerify = true
smtpUser = 1426115933@qq.com
from = 1426115933@qq.com
smtpPass = (企业邮箱密码或者授权码)
[container]
javaOptions = "-Dflogger.backend_factory=com.google.common.flogger.backend.log4j.Log4jBackendFactory#getInstance"
javaOptions = "-Dflogger.logging_context=com.google.gerrit.server.logging.LoggingContext#getInstance"
user = gerrit2
javaHome = /usr/lib/jvm/java-8-openjdk-amd64/jre
heapLimit = 4g
[sshd]
listenAddress = *:29418
[httpd]
listenUrl = proxy-http://*:8081/
[cache]
directory = cache
[gitweb]
cgi = /usr/lib/cgi-bin/gitweb.cgi
type = gitweb
[index]
type = lucene
[receive]
enableSignedPush = false
[capability]
accessDatabase = group Administrators
[plugins]
allowRemoteAdmin = true
chown -R gerrit2.gerrit2 /home/gerrit2
apt-get install apache2 -y
vim /etc/apache2/httpd.conf
<VirtualHost *>
ServerName localhost
ProxyRequests Off
ProxyVia Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location "/login/">
AuthType Basic
AuthName "Gerrit Code Review"
AuthBasicProvider file
Require valid-user
AuthUserFile /home/gerrit2/gerrit_site/etc/passwords
</Location>
AllowEncodedSlashes On
ProxyPass / http://127.0.0.1:8081/ nocanon
</VirtualHost>
vim ports.conf
...
Listen 8080
...
vim apache2.conf
...
Include ports.conf
Include httpd.conf
...
cd /etc/apache2/mods-enabled/
sudo ln -s ../mods-available/proxy.load
sudo ln -s ../mods-available/proxy.conf
sudo ln -s ../mods-available/proxy_http.load
sudo ln -s ../mods-available/proxy_balancer.conf
sudo ln -s ../mods-available/proxy_balancer.load
sudo ln -s ../mods-available/rewrite.load
sudo ln -s ../mods-available/ssl.conf
sudo ln -s ../mods-available/ssl.load
sudo ln -s ../mods-available/slotmem_shm.load
sudo ln -s ../mods-available/socache_shmcb.load
touch /home/gerrit2/gerrit_site/etc/passwords
htpasswd -b /home/gerrit2/gerrit_site/etc/passwords admin admin
apt-get install gitweb -y
vim /lib/systemd/system/gerrit.service
[Unit]
Description=Gerrit Web System.
After=network.target
[Service]
Type=forking
User=gerrit2
EnvironmentFile=/home/gerrit2/gerrit_site/etc/gerrit.config
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=gerrit
ExecStart=/home/gerrit2/gerrit_site/bin/gerrit.sh start
ExecStop=/home/gerrit2/gerrit_site/bin/gerrit.sh stop
PIDFile=/home/gerrit2/gerrit_site/logs/gerrit.pid
[Install]
WantedBy=multi-user.target
systemctl start apache2.service
systemctl enable apache2.service
systemctl start gerrit.service
systemctl enable gerrit.service
http://172.16.3.50:8080/