Ubuntu 上 gerrit 服务器的搭建

来源:互联网 发布:c语言关键字及其含义 编辑:程序博客网 时间:2024/06/16 19:58

平台: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 80Listen 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/passwdhtpasswd -b ./review_site/etc/passwd admin 123

开启一些模块

sudo a2enmod proxysudo a2enmod rewritesudo a2enmod sslsudo a2enmod proxy_balancersudo 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 startsudo /etc/init.d/apache2 restart

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