Ubuntu 上 gerrit 服务器的搭建

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

平台:Ubuntu

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

安装,全部默认

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

建立git仓库

mkdir /home/gerrit/repositories

修改gerrit配置文件

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

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

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访问啦

猜你在找的Ubuntu相关文章