Gerrit的搭建在Linux系统下的资料比较多,而在Windows系统上的参考资料相对较少,有些配置也需要一定的技巧才能解决,这些记录说明一下过程。
另外,本次配置的环境也比较特别,运行Gerrit服务的主机IP是192.168.1.198, 它是一台局域网机器,通过共用的外网来连接外网。我们要从外网来访问这台局域网运行的gerrit服务器。
所需基本软件版本都选择较新的:git-2.18, jdk-1.8, gerrit-2.15.3, apache 2.2.
这四者的安装都按照常规安装即可,最后所有的配置都通过修改配置文件来进行,具体安装过程可参考gerrit 在win7下安装总结. 安装完成后,要设置好这4个软件软件的PATH环境变量,方便后续执行。
以下主要列举说明主要配置的要点。
Apache的配置文件在D:GITApache2.2f,首先打开如下模块,即去掉前面的#号即可:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule negotiation_module modules/mod_negotiation.so
然后设置
<VirtualHost *:8080>
ServerName localhost
ProxyRequests Off
ProxyVia Off
ProxyPreserveHost On
AllowEncodedSlashes On<Proxy *:8080>
Order deny,allow
Allow from all
</Proxy><Location /login/>
AuthType Basic
AuthName “Gerrit Code Review”
Require valid-user
AuthUserFile D:/GIT/htpasswd
</Location>ProxyPass / :9080/ nocanon
ProxyPassReverse / 192.168.1.198:9080/</VirtualHost>
其中
AllowEncodedSlashes On
ProxyPass / :9080/ nocanon
的设置非常重要,解决查看二级目录下Apache对”/”的编码导致的gerrit无法识别路径的问题。
上面还一个ProxyPassReverse的设置,并没有设置与ProxyPass相同,这也是根据实际调试结果,当Apache完成用户认证后进行跳转,需要此项。
在命令行中执行 -k install ,安装apache到服务中,通过“计算机管理”-“服务”可查看,进行重启等操作,其默认服务名称为”Apache 2.2”.
其配置文件在 D:GITgerritfig,内容配置如下:
>
[gerrit]
basePath = git
serverId = e6534ffd-9199-45a4-a2eb-177649829d1a
canonicalWebUrl = 192.168.1.198:9080/
[database]
type = h2
database = D:GITgerritdbReviewDB
[noteDb “changes”]
disableReviewDb = true
primaryStorage = note db
read = true
sequence = true
write = true
[index]
type = LUCENE
[auth]
type = HTTP
logoutUrl = aa:aax:8080/logout
[receive]
enableSignedPush = false
[sendemail]
[sendemail]
smtpServer = smtp.163
smtpUser = xx@163
smtpPass = userpass
from = xx@163
[container]
user = gerrit
javaHome = C:Program FilesJavajre1.8.0_181
[sshd]
listenAddress = *:29418
[httpd]
listenUrl = *:9080/
[cache]
directory = cache
[gitweb]
type = gitweb
cgi = “C:Program FilesGitmingw32sharegitwebgitweb.bat”
可通过执行gerrit.sh restart进行重启等操作。执行gerrit.sh run进行调试工作,实时打印log信息。
下面主要说明的是gitweb的配置
其中gitweb.bat的内容如下:
@echo off
“C:Program FilesGitusr” C:”Program Files”Gitmingw32sharei %*
主要参考在window上集成Gitweb和Gerrit, 主要问题是在Windows版本的Git上,gitweb的支持并不好,需要安装CGI模块,可以从这里下载CGI.pm-3.65最新版本。
然后把CGI.pm-3.65/lib/目录中的内容复制到C:Program FilesGitmingw32shareperl5site_perl中。 把创建的gitweb.bat放在C:Program FilesGitmingw32sharegitweb中。
在测试中发现执行gitweb.bat时,系统并不从mingw32目录中搜索相关CGI.pm,所以将mingw32shareperl5site_perl目录复制到usrshareperl5中。
还需要修改C:Program FilesGitmingw32sharei中如下两个设置:
>
# core git executable to use
# this can just be “git” if your webserver has a sensible PATH
our $GIT = “/mingw64/bin/git”;# absolute fs-path which will be prepended to the project path
our $projectroot = “/d/GIT/gerrit/git”;
其中* our $GIT * 设置的git命令的安装位置,系统一般自动设置,此项一般不需要修改。
our $projectroot则需要设置gerrit中代码仓库的目录位置。
在上面f设置项[gitweb]配置中还要加上
type=gitweb
测试时发现,没有加此项gitweb仍无法正常工作。
另外注意,还要修改refs/meta/config权限,允许普通注册用户查看gitweb, 否则,即使前面都配置正确,仍然会页面Not Found的提示。
好了,基本要点完毕。
本文发布于:2025-04-06 12:09:00,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/1743912606584658.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |