1 - GitWeb简介

GitWeb是一个支持在Web页面上查看代码以及提交信息的工具。

安装GitWeb工具并且集成到Gerrit中,就可以直接在Gerrit的项目列表中查看项目的代码信息。

2 - 安装GitWeb

启动gerrit服务

[gerrit@mt101 ~]$ sudo gerrit_testsite/bin/gerrit.sh start
Starting Gerrit Code Review: OK
[gerrit@mt101 ~]$
[gerrit@mt101 ~]$ sudo service nginx start
Redirecting to /bin/systemctl start nginx.service
[gerrit@mt101 ~]$



通过yum安装GitWeb

[gerrit@mt101 ~]$ sudo yum -y install gitweb
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
mongodb-org-4.0 | 2.5 kB 00:00:00
nginx-stable | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package gitweb.noarch 0:1.8.3.1-20.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================================
Package Arch Version Repository Size
=====================================================================================================
Installing:
gitweb noarch 1.8.3.1-20.el7 base 112 k

Transaction Summary
=====================================================================================================
Install 1 Package

Total download size: 112 k
Installed size: 320 k
Downloading packages:
gitweb-1.8.3.1-20.el7.noarch.rpm | 112 kB 00:00:07
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : gitweb-1.8.3.1-20.el7.noarch 1/1
Verifying : gitweb-1.8.3.1-20.el7.noarch 1/1

Installed:
gitweb.noarch 0:1.8.3.1-20.el7

Complete!
[gerrit@mt101 ~]$

3 - 设置projectroot目录

配置文件:/etc/gitweb.conf 

[gerrit@mt101 ~]$ sudo vim /etc/gitweb.conf
[gerrit@mt101 ~]$ sudo cat /etc/gitweb.conf |grep -v "#" |grep -Ev "^$"
our $projectroot = "/home/gerrit/gerrit_testsite/git"
[gerrit@mt101 ~]$

4 - 配置GitWeb的httpd服务

4.1 配置GitWeb路径

GitWeb是基于httpd服务工作的,配置文件:/etc/httpd/conf.d/git.conf

[gerrit@mt101 ~]$ sudo cat /etc/httpd/conf.d/git.conf
Alias /git /var/www/git

<Directory /var/www/git>
Options +ExecCGI
AddHandler cgi-script .cgi
DirectoryIndex gitweb.cgi
</Directory>
[gerrit@mt101 ~]$
[gerrit@mt101 ~]$ sudo vim /etc/httpd/conf.d/git.conf
[gerrit@mt101 ~]$
[gerrit@mt101 ~]$ sudo cat /etc/httpd/conf.d/git.conf
Alias /gitweb /var/www/git
SetEnv GITWEB_CONFIG /etc/gitweb.conf
<Directory /var/www/git>
Options +ExecCGI +FollowSymLinks +SymLinksIfOwnerMatch
AllowOverride All
order allow,deny
Allow from all
AddHandler cgi-script .cgi
DirectoryIndex gitweb.cgi
</Directory>
[gerrit@mt101 ~]$

4.2 配置服务端口

/etc/httpd/conf/httpd.conf中配置服务端口

[gerrit@mt101 ~]$ sudo cat /etc/httpd/conf/httpd.conf |grep -v "#" |grep -Ev "^$" |grep -i listen
Listen 80
[gerrit@mt101 ~]$
[gerrit@mt101 ~]$ sudo vim /etc/httpd/conf/httpd.conf
[gerrit@mt101 ~]$ sudo cat /etc/httpd/conf/httpd.conf |grep -v "#" |grep -Ev "^$" |grep -i listen
Listen 8084
[gerrit@mt101 ~]$

4.3 重启httpd服务

[gerrit@mt101 ~]$ sudo systemctl restart httpd.service
[gerrit@mt101 ~]$ sudo systemctl status httpd.service
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: active (running) since Tue 2019-12-10 22:57:22 CST; 9s ago
Docs: man:httpd(8)
man:apachectl(8)
Process: 3432 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=0/SUCCESS)
Main PID: 3439 (httpd)
Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"
Tasks: 7
CGroup: /system.slice/httpd.service
├─3439 /usr/sbin/httpd -DFOREGROUND
├─3440 /usr/sbin/httpd -DFOREGROUND
├─3441 /usr/sbin/httpd -DFOREGROUND
├─3442 /usr/sbin/httpd -DFOREGROUND
├─3443 /usr/sbin/httpd -DFOREGROUND
├─3444 /usr/sbin/httpd -DFOREGROUND
└─3445 /usr/sbin/httpd -DFOREGROUND

Dec 10 22:57:16 mt101 systemd[1]: Starting The Apache HTTP Server...
Dec 10 22:57:21 mt101 httpd[3439]: AH00558: httpd: Could not reliably determine the server's f...sage
Dec 10 22:57:22 mt101 systemd[1]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
[gerrit@mt101 ~]$

4.4 开放防火墙

[gerrit@mt101 ~]$ sudo firewall-cmd --zone=public --permanent --add-port=8084/tcp
success
[gerrit@mt101 ~]$ sudo firewall-cmd --reload
success
[gerrit@mt101 ~]$ sudo firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: enp0s3 enp0s8
sources:
services: ssh dhcpv6-client
ports: 8080/tcp 80/tcp 83/tcp 8083/tcp 8084/tcp
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules: [gerrit@mt101 ~]$

5 - 访问GitWeb

6 - 和Gerrit集成

6.1 更新Gerrit配置文件

增加如下部分

[gitweb]
type = gitweb
cgi = /var/www/git/gitweb.cgi
[gerrit@mt101 ~]$ sudo vim gerrit_testsite/etc/gerrit.config
[gerrit@mt101 ~]$ sudo cat gerrit_testsite/etc/gerrit.config
[gerrit]
basePath = git
canonicalWebUrl = http://192.168.16.101:8083/
serverId = 0b911b9e-195a-46b0-a5cd-b407b776b344
[container]
javaOptions = "-Dflogger.backend_factory=com.google.common.flogger.backend.log4j.Log4jBackendFactory#getInstance"
javaOptions = "-Dflogger.logging_context=com.google.gerrit.server.logging.LoggingContext#getInstance"
user = root
javaHome = /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.161-2.b14.el7.x86_64/jre
[index]
type = lucene
[auth]
type = HTTP
[receive]
enableSignedPush = false
[sendemail]
smtpServer = localhost
[sshd]
listenAddress = *:29418
[httpd]
listenUrl = http://192.168.16.101:8083/
[cache]
directory = cache
[gitweb]
type = gitweb
cgi = /var/www/git/gitweb.cgi
[gerrit@mt101 ~]$

6.2 修改git配置

[gerrit@mt101 ~]$ git config --file /home/gerrit/gerrit_testsite/etc/gerrit.config gitweb.cgi /var/www/git/ gitweb.cgi
[gerrit@mt101 ~]$ git config --file /home/gerrit/gerrit_testsite/etc/gerrit.config --unset gitweb.url
[gerrit@mt101 ~]$

6.3 重启Gerrit服务

[gerrit@mt101 ~]$ sudo gerrit_testsite/bin/gerrit.sh restart
Stopping Gerrit Code Review: OK
Starting Gerrit Code Review: OK
[gerrit@mt101 ~]$

6.4 重新登录,确认GitWeb链接

BROWSE---》Repositories---》Repository Browser---》gitweb链接

点击All-Project的gitweb链接

6.5 配置GitWeb访问权限

默认只有Gerrit管理员用户才有GieWeb的访问权限。

BROWSE---》Repositories---》All-Projects---》Access---》Reference: refs/meta/config

在“refs/meta/config”的Read选项中添加“Registered Users”的ALLOW 权限

Gerrit - 安装配置GitWeb的更多相关文章

  1. gerrit安装配置记录

    gerrit安装配置 java -jar gerrit-2.13.5.war init -d gerrit Authentication method [OPEN/?]: htt Install Ve ...

  2. Gerrit安装配置

    环境: CentOS 1611 + gerrit-2.11.4 (review.openstack.org) 1. 安装java1.8 (>1.7) [root@review ~]# yum i ...

  3. 安装配置gerrit

    Centos 安装配置gerrit 关闭selinux,不然nginx的反向代理会报错connect() to 127.0.0.1:8080 failed (13: Permission denied ...

  4. gerrit+nginx+centos安装配置

    安装环境 centos 6.8 gerrit-full-2.5.2.war 下载地址:https://gerrit-releases.storage.googleapis.com/gerrit-ful ...

  5. Gerrit+apache+H2数据库简单安装配置及建库流程

    Gerrit 是一个基于 Web 的代码评审和项目管理的工具,面向基于 Git 版本控制系统的项目.因此需要Apache.Mysql.GIT等相关软件的支持 系统配置: 新装的UBANTU LINUX ...

  6. Gerrit安装

    1.安装gerrit [sisi@pre-srv44 ~]$ su - gerrit2Password: [gerrit2@pre-srv44 ~]$ lltotal 83872-rw-r--r-- ...

  7. Gerrit2安装配置

    我主要根据下面这个文章而安装,遇到一些小问题,记录如下:2016.4.30 安装 2.12.2,要将加密的东东全装上!!!注意                      1) 由于新的git-bash ...

  8. Centos7安装配置gitlab

    Centos7安装配置gitlab 这篇文字我会介绍在Centos7上安装gitlab,配置gitlab的smtp,并且创建项目demo. sudo yum install openssh-serve ...

  9. Git服务器的Gitosis安装配置及gitignore的使用方法

    Git服务器Gitosis安装设置 1.安装 openssh服务器 sudo apt-get install openssh-server openssh-client 2.创建个人公钥和私钥 在默认 ...

随机推荐

  1. python的email、smtplib、poplib模块收发邮件

    一封电子邮件的旅程是: MUA:Mail User Agent--邮件用户代理.(即类似Outlook的电子邮件软件) MTA:Mail Transfer Agent--邮件传输代理,就是那些Emai ...

  2. iis7设置http跳转https实测可用

    前面ytkah和大家聊了Apache设置http如何301到https,现在我们说说iis7设置http跳转https,因为还是有很多人在用iis服务器.首先要先安装url rewrite modul ...

  3. hook杂思-面向函数编程

    hook:方法拦截 以函数单元为编程对象: 在编译时或运行时进行函数单元的替代.修改.功能添加操作: 所有的操作都不是在原始编码时完成的: 函数单元作为参量.操作对象.编码对象存在于机制中: 机制: ...

  4. moya

    https://juejin.im/post/5ac2cf34f265da23a1421483 https://juejin.im/post/5a69e9f9f265da3e290c6782

  5. 伯克利套接字(BSD Socket)

    http://blog.csdn.net/blueman2012/article/details/6693605#socket.28.29 伯克利套接字(Berkeley sockets),也称为BS ...

  6. Git常用命令与入门

    Git 仓库就是那个.git 目录,其中存放的是我们所提交的文档索引内容,Git 可基于文档索引内容对其所管理的文档进行内容追踪,从而实现文档的版本控制..git目录位于工作目录内.对于任何一个文件, ...

  7. 第08组 Alpha事后诸葛亮

    组长博客 点这里! 总结思考 设想和目标 我们的软件要解决什么问题?是否定义得很清楚?是否对典型用户和典型场景有清晰的描述? 弥补Powerpoint中模板转换存在的缺陷,完善PPT模板一键转换的功能 ...

  8. Nagios HTTP WARNING: HTTP/1.1 403 Forbidden

    当我们第一次搭建好nagios后会有Nagios HTTP WARNING: HTTP/1.1 403 Forbidden告警 要解决这个问题, 可以创建一个html文件,然后重启两个服务,等待几分钟 ...

  9. python 项目实战之装饰器

    import logging def use_logging(func): def writelog(*args, **kwargs): logging.warning("%s is run ...

  10. C++11原子操作与无锁编程(转)

    不讲语言特性,只从工程角度出发,个人觉得C++标准委员会在C++11中对多线程库的引入是有史以来做得最人道的一件事:今天我将就C++11多线程中的atomic原子操作展开讨论:比较互斥锁,自旋锁(sp ...