Integrate gitweb with gerrit in centos

Why we choose gerrit with gitweb rather than gitlab or github ?

Gerrit with gitweb is lighter than gitlab/github, can responsible for code review, best of all, we can add functions which we need rather than owning all functions and most of them we’ll never use.

Gerrit is a free, web-based team code collaboration tool. Software developers in a team can review each other’s modifications on their source code using a web browser and approve or reject those changes. It integrates closely with Git, a distributed version control system.

Gerrit Code Review can manage and generate hyperlinks to gitweb, allowing users to jump from gerrit content to the same information, but shown by gitweb.

(1) Init database.

mysql > create user 'gerrit2'@'localhost' identified by 'gerrit2';

mysql > create database reviewdb;

mysql > alter database reviewdb charset=latin1;

mysql > grant all on reviewdb.* to 'gerrit2'@'localhost';

mysql > flush privileges;

(2) Install gerrit

ivan@ivan cp gerrit-2.3.war /usr/local
ivan@ivan cd /usr/local
ivan@ivan java -jar gerrit-.2.3.war init -d review_site

(3) Create password file.

ivan@ivan mkdir /etc/nginx/passwd
ivan@ivan htpasswd -c /etc/nginx/passwd/gerrit2.passwd gerrit2

(4) Nginx configuration about gerrit.

server {
listen 80;
server_name gerrit.**.**.**
location /gerrit/ {
proxy_set_header X-Forwarded-For    $remote_addr
proxy_set_header Host $host;
auth_basic  "Gerrit Code Review";
auth_basic_user_file /etc/nginx/passwd/gerrit2.passwd
error_page    401        /401.html;
location = /401.html {
root        /usr/share/nginx/html;

(5) Install gitweb.

ivan@ivan yum install gitweb (default gitweb install dir is /var/www/git)
ivan@ivan cp -r /var/www/git /usr/share/works/git/;

(6) Configuration about integrating gerrit with gitweb.

ivan@ivan cat /etc/gitweb.conf


$projectroot = '/home/wjl/dev_software/git';
$site_name = "Waijule code reviewers"
$my_uri = "/";
$home_link = "/";
@stylesheets = ("/gitweb.css");
$favicon = "/git-favicon.png";
$logo = "/git-logo.png"


(7) Nginx configuration of gitweb.

server {
listen 80;
server_name gerrit.**.**.**
location /gitweb.cgi {
root /usr/share/works/git/;
include fastcgi_params;
gzip off;
fastcgi_param SCRIPT_NAME $uri;
fastcgi_param GITWEB_CONFIG /etc/gitweb.conf;
fastcgi_pass    unix:/var/run/fcgiwrap.socket;

location / {
root /usr/share/works/git/;
index gitweb.cgi;

(8) Install fcgiwrap

Fcgiwrap is a simple server for running CGI applications over FastCGI. It hopes to provide clean CGI support to Nginx (and other web servers that may need it)

ivan@ivan yum groupinstall 'Development tools'
ivan@ivan yum install fcgi-devel
ivan@ivan cd /usr/local/src/
ivan@ivan git clone git://
ivan@ivan cd fcgiwrap
ivan@ivan autoreconf -i
ivan@ivan ./configure
ivan@ivan make & make install

(9) Install spawn-cgi which allows us to run fcgiwrap as a daemon.

ivan@ivan yum install spawn-fcgi
ivan@ivan vim /etc/sysconfig/spawn-fcgi
ivan@ivan chkconfig --level 235 spawn-fcgi on
ivan@ivan /etc/init.d/spawn-fcgi start

(10) Import individual project into gerrit. (Assumes that one project called Waijule exists.)

ivan@ivan vim /home/ivan/project/waijule/.git/description
It provides most services for Waijule Inc.

ivan@ivan cp -r /home/ivan/project/Waijule/.git /usr/share/works/git/Waijule.git

Refer to :






















电子邮件地址不会被公开。 必填项已用*标注

您可以使用这些HTML标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>