ubuntu18.04搭建gerrit-2.15.6

一、gerrit下载路径
gerrit下载连接可参考https://www.gerritcodereview.com

二、Ubuntu新增gerrit账号
1.sudo su

2.sudo adduser gerrit

3.vim /etc/sudoers 添加sudo权限 root ALL=(ALL:ALL) ALL”这一行下面加入一行:gerrit ALL=(ALL:ALL) ALL

三、Ubuntu安装java环境
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-8-jdk

四、安装git
sudo apt-get install git

五、安装Apache2
sudo apt-get install apache2

六、配置Apache2
1.进入apache2设置目录

cd /etc/apache2

2.修改三个配置文件:

httpd.conf
apache2.conf
ports.conf

备注:httpd.conf文件没有的话需要手动创建

sudo touch /etc/apache2/httpd.conf
sudo vim /etc/apache2/httpd.conf

配置httpd.conf

<VirtualHost *:8080>

ServerName 192.168.8.xxx

ProxyRequests Off
ProxyVia Off
ProxyPreserveHost On

<Proxy *>
      Order deny,allow
      Allow from all
</Proxy>

<Location "/login/">
    AuthType Basic
    AuthName "Gerrit Code Review"
    Require valid-user
    AuthBasicProvider file
    AuthUserFile /home/ssd4/gerrit/gerrit/review_site/passwords
</Location>

AllowEncodedSlashes On

ProxyPass / http://192.168.8.xxx:8091/ nocanon

ProxyPassReverse / http://192.168.8.xxx:8091/
按照以上配置 192.168.8.xxx是gerrit ip地址,ubuntu命令查看ip地址:ifconfig

配置apache2.conf

Include of directories ignores editors’ and dpkg’s backup files,

see README.Debian for details.

Include generic snippets of statements

IncludeOptional conf-enabled/*.conf

Include the virtual host configurations:

IncludeOptional sites-enabled/*.conf

vim: syntax=apache ts=4 sw=4 sts=4 sr noet

#添加这行代码
Include httpd.conf
/etc/apache2/apache2.conf文件最后一行加上:Include httpd.conf

配置ports.conf

Listen 80

Listen 443

Listen 8080
#这里的8081端口号是上面配置的Apache2反射端口

vim: syntax=apache ts=4 sw=4 sts=4 sr noet

/etc/apache2/ports.conf 文件最后一行添加:Listen 8080

开启SSL、Proxy、Rewrite等模块:

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

七、解压gerrit.war和配置gerrit.config文件
解压安装gerrit.war安装包

java -jar gerrit.war init -d ~/review_site

配置gerrit.config文件

[gerrit]
basePath = git
serverId = 09cf5f00-2d6d-496f-840f-2c712989de9f
canonicalWebUrl = http://192.168.8.xxx:8080/
[database]
type = h2
database = /home/ssd4/gerrit/gerrit/review_site/db/ReviewDB
[noteDb “changes”]
disableReviewDb = true
primaryStorage = note db
read = true
sequence = true
write = true
[index]
type = LUCENE
[auth]
type = HTTP
[oauth]
allowEditFullName = true
allowRegisterNewEmail = true
[receive]
enableSignedPush = false
maxBatchCommits = 10000000 #最大提交数的限制
[sendemail]
enable = true
smtpServer = 218.103.102.1
smtpServerPort = 25
smtpEncryption =
sslVerify = false
smtpUser = gerrit_urovo.com
smtpPass = gerrit2018!
[container]
user = gerrit01
javaHome = /usr/lib/jvm/java-8-openjdk-amd64/jre
[sshd]
listenAddress = :29418
[httpd]
listenUrl = http://
:8091/
[cache]
directory = cache
[gitweb]
type = gitweb
cgi = /usr/lib/cgi-bin/gitweb.cgi #gitweb安装好后在此处配置下就行
按照这样配置

新增管理员账号

//这个文件就是上面Apache配置的账号路径
touch gerrit/gerrit/review_site/passwords
//新增账号admin和密码
sudo htpasswd -b gerrit/gerrit/review_site/passwords admin admin

安装Gitweb
sudo apt-get install gitweb

八、重启Apache2和Gerrit
sudo /home/gerrit/review_site/bin/gerrit.sh restart
sudo /etc/init.d/apache2 restart

九、gerrit常用命令
进入gerrit的bin目录

gerrit.sh start 启动gerrit

gerrit.sh stop 停止gerrit

gerrit.sh restart 重启gerrit
————————————————
版权声明:本文为CSDN博主「weixin_46206723」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_46206723/article/details/124077221

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值