Ubuntu 上 gerrit 服务器的搭建

前端之家收集整理的这篇文章主要介绍了Ubuntu 上 gerrit 服务器的搭建前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

平台:Ubuntu

需要JDK环境,下载gerrit放根目录

安装,全部默认

  1. java -jar gerrit-2.13.6.war init -d review_site

建立git仓库

  1. mkdir /home/gerrit/repositories

修改gerrit配置文件

  1. nano review_site/etc/gerrit.config

修改如下

  1. [gerrit]
  2. basePath = /home/gerrit/repositories
  3. serverId = 8c30499b-3156-4992-8254-a905239811b5
  4. canonicalWebUrl = http://192.168.137.6:8888/
  5. [database]
  6. type = h2
  7. database = /home/gerrit/review_site/db/ReviewDB
  8. [auth]
  9. type = HTTP
  10. [receive]
  11. enableSignedPush = false
  12. [sendemail]
  13. smtpServer = smtp.exmail.qq.com
  14. smtpServerPort = 465
  15. smtpEncryption = SSL
  16. smtpUser = ming.yang@yidatec.com
  17. smtpPass = !QAZ2wsx
  18. from = ming.yang@yidatec.com
  19. [container]
  20. user = gerrit
  21. javaHome = /opt/jdk1.8.0_121/jre
  22. [sshd]
  23. listenAddress = *:29418
  24. [httpd]
  25. listenUrl = http://192.168.137.6:8888/
  26. [cache]
  27. directory = cache

安装apache2

  1. sudo apt install apache2

修改配置

  1. sudo nano /etc/apache2/ports.conf

新增9999端口

  1. . . . . . .
  2. Listen 80
  3. Listen 9999
  4. . . . . . .

配置反向代理

  1. sudo nano /etc/apache2/httpd.conf
  1. ServerName gerrit.com
  2. <VirtualHost *:9999>
  3. ProxyRequests Off
  4. ProxyVia Off
  5. ProxyPreserveHost On
  6. AllowEncodedSlashes On
  7. RewriteEngine On
  8. RewriteRule ^/(.*) http://192.168.137.6:8888/$1 [NE,P]
  9.  
  10. <Proxy *>
  11. Order deny,allow
  12. Allow from all
  13. </Proxy>
  14.  
  15. <Location /login/>
  16. AuthType Basic
  17. AuthName "Gerrit Code Review"
  18. Require valid-user
  19. AuthBasicProvider file
  20. AuthUserFile /home/gerrit/review_site/etc/passwd
  21. </Location>
  22.  
  23. ProxyPass / http://192.168.137.6:8888/
  24.  
  25. </VirtualHost>

配置文件中加入httpd.conf,使其生效

  1. sudo nano /etc/apache2/apache2.conf

加一句

  1. Include httpd.conf

新建gerrit管理员用户,设置帐号密码

  1. touch ./review_site/etc/passwd
  2. htpasswd -b ./review_site/etc/passwd admin 123

开启一些模块

  1. sudo a2enmod proxy
  2. sudo a2enmod rewrite
  3. sudo a2enmod ssl
  4. sudo a2enmod proxy_balancer
  5. sudo a2enmod proxy_http

关掉gerrit服务

  1. ./review_site/bin/gerrit.sh stop

清空数据库

  1. cd review_site/bin/
  2. java -jar ./gerrit.war gsql -d ../
  3. DROP ALL OBJECTS;

不这样做会有Server Error,Missing project All-Projects的错误

  1. java.lang.IllegalStateException: Missing project All-Projects

重新安装一遍gerrit

  1. java -jar gerrit-2.13.6.war init -d review_site

启动服务

  1. ./review_site/bin/gerrit.sh start
  2. sudo /etc/init.d/apache2 restart

客户端可通过http://192.168.137.6:9999访问啦

猜你在找的Ubuntu相关文章