gerrit@aptivadp:~ $ java -jar Downloads/gerrit-2.16.2.war init -d gerrit Using secure store: com.google.gerrit.server.securestore.DefaultSecureStore [2019-01-08 16:39:04,277] [main] INFO com.google.gerrit.server.config.GerritServerConfigProvider : No /home/gerrit/gerrit/etc/gerrit.config; assuming defaults
*** Gerrit Code Review 2.16.2 ***
*** Git Repositories ***
Location of Git repositories [git]:
*** SQL Database ***
Database server type [h2]: mysql Server hostname [localhost]: Server port [(mysql default)]: Database name [reviewdb]: gerritdb #前面设置的数据库名 Database username [gerrit]: gerrituser #前面授权的用户 gerrituser's password : #连续输入两次密码gerritpass confirm password :
*** Index ***
Type [lucene/?]:
*** User Authentication ***
Authentication method [openid/?]: http Get username from custom HTTP header [y/N]? SSO logout URL : Enable signed push support [y/N]?
*** Review Labels ***
Install Verified label [y/N]?
*** Email Delivery ***
SMTP server hostname [localhost]: SMTP server port [(default)]: SMTP encryption [none/?]: SMTP username :
*** Container Process ***
Run as [gerrit]: gerrit Java runtime [/usr/lib/jvm/java-8-openjdk-amd64/jre]: Copy gerrit-2.16.2.war to gerrit/bin/gerrit.war [Y/n]? Copying gerrit-2.16.2.war to gerrit/bin/gerrit.war
*** SSH Daemon ***
Listen on address [*]: Listen on port [29418]: Generating SSH host key ... rsa... ed25519... ecdsa 256... ecdsa 384... ecdsa 521... done
*** HTTP Daemon ***
Behind reverse proxy [y/N]? y #选择y Proxy uses SSL (https://) [y/N]? Subdirectory on proxy server [/]: Listen on address [*]: Listen on port [8081]: 8082 Canonical URL [http://aptivadp.com/]: http://10.243.54.188
*** Cache ***
*** Plugins ***
Installing plugins. Install plugin codemirror-editor version v2.16.2 [y/N]? y Installed codemirror-editor v2.16.2 Install plugin commit-message-length-validator version v2.16.2 [y/N]? y Installed commit-message-length-validator v2.16.2 Install plugin download-commands version v2.16.2 [y/N]? y Installed download-commands v2.16.2 Install plugin hooks version v2.16.2 [y/N]? y Installed hooks v2.16.2 Install plugin replication version v2.16.2 [y/N]? y Installed replication v2.16.2 Install plugin reviewnotes version v2.16.2 [y/N]? y Installed reviewnotes v2.16.2 Install plugin singleusergroup version v2.16.2 [y/N]? y Installed singleusergroup v2.16.2 Initializing plugins.
Initialized /home/gerrit/gerrit Reindexing projects: 100% (2/2) with: reindex --site-path gerrit --threads 1 --index projects Reindexed 2 documents in projects index in 0.1s (32.8/s)
ProxyRequests Off ProxyVia Off ProxyPreserveHost On
<Proxy *> # Order deny,allow # Allow from all # 在 Apache >= 2.4的版本上可以用下面这句代替上面两句 # Use following line instead of the previous two on Apache >= 2.4 Require all granted </Proxy>
#ProxyPass / http://10.243.54.188:8088/ #proxyPassReverse / http://127.0.0.1:8088/ AllowEncodedSlashes On ProxyPass / http://127.0.0.1:8088/ nocanon # The two options 'AllowEncodedSlashes On' and 'ProxyPass .. nocanon' are required since Gerrit 2.6. </VirtualHost>
同时需要配置 /etc/apache2/ports.conf ,添加所需的端口:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
# If you just change the port or add more ports here, you will likely also # have to change the VirtualHost statement in # /etc/apache2/sites-enabled/000-default.conf
$ cat gerit/bin/gerrit.sh | head -n 50 # Configuration files: # # /etc/default/gerritcodereview # If it exists, sourced at the start of this script. It may perform any # sequence of shell commands, like setting relevant environment variables. # # The files will be checked for existence before being sourced. # Configuration variables. These may be setin /etc/default/gerritcodereview. # # GERRIT_SITE # Path of the Gerrit site to run. $GERRIT_SITE/etc/gerrit.config # will be used to configure the process. # # GERRIT_WAR # Location of the gerrit.war download that we will execute. Defaults to # container.war property in$GERRIT_SITE/etc/gerrit.config. # # NO_START # If set to "1" disables Gerrit from starting. # 从以上注释得知 /etc/default/gerritcodereview 为配置文件,如下配置开机启动 $ sudo ln -snf /home/gerrit/gerrit/bin/gerrit.sh /etc/init.d/gerrit.sh $ sduo ln -snf /etc/init.d/gerrit.sh /etc/rc2.d/S90gerrit $ sduo ln -snf /etc/init.d/gerrit.sh /etc/rc3.d/S90gerrit # 自动启动脚本 /etc/init.d/gerrit.sh 需要通过 /etc/default/gerritcodereview 文件来提供一些配置 $ sudo cat /etc/default/gerritcodereview # 内容如下 GERRIT_SITE=/home/gerrit/gerrit NO_START=0 # 值为 1 时取消开机启动