gerrit安装指南(ubuntu环境)

本次安装指南所用环境为ubuntu14.04

gerrit.war需要自行到https://www.gerritcodereview.com/下载

step1:仓库的更新以及Apache2以及相关组件安装

sudo apt-get update

sudo apt-get upgrade

sudo apt-get clean

sudo apt-get install apache2                                              #安装apache2 若系统自带可以跳过此步

sudo apt-get install apache2-utils

sudo a2enmod proxy_http                                                 #开启代理模块

sudo a2enmod proxy_balancer                                          #开启负载均衡模块

sudo apt-get install libapache2-mod-php5 php5

sudo apt-get install php5-curl

sudo service apache2 restart                                             #启动apache2

在启动apache2时,会有一条关于ServerName的警告可以忽略不计

step2:下面开始安装jdk,若系统已有jdk,请跳过

sudo apt-get install default-jre

sudo apt-get install default-jdk

sudo apt-get install openjdk-7-jre

sudo apt-get install openjdk-7-jdk

sudo apt-get install git

step3:mysql数据库安装以及配置

sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql

mysql-uroot-p                                                               #进入数据库

show databases;

CREATE USER 'gerrit2'@'localhost' IDENTIFIED BY 'secret';

SET PASSWORD FOR'gerrit2'@'localhost'=PASSWORD('数据库密码');

CREATE DATABASE reviewdb;

GRANT ALL ON reviewdb.*TO'gerrit2'@'localhost';

FLUSH PRIVILEGES;

exit

step4:对apache2进行配置

sudo vim/etc/apache2/ports.conf

Listen8080                                                                  #此处我监听的是8080端口,大家根据需要进行修改

step5:配置apache2代理文件

sudo vim/etc/apache2/sites-available/gerrit.conf

将<VirtualHost *:8080>...</VirtualHost>拷贝到gerrit.conf,x.x.x.x需要自己配置

<VirtualHost *:8080>

        ServerName x.x.x.x

        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/gerrit2/pwd

        </Location>

        AllowEncodedSlashes On

        ProxyPass / http://x.x.x.x:8081/ nocanon

</VirtualHost>

sudo a2ensite gerrit.conf                                                       #启用该代理

sudo service apache2 restart

step6:创建并切换到gerrit2用户,配置并配置gerrit

sudo adduser gerrit2

sudo su gerrit2

java -jar gerrit-2.10.war init -d /home/gerrit2/gerrit/          #此处需要将要安装的gerrit.war拷到~目录下

接下来就要对gerrit配置项进行选择

Create '/home/gerrit2/gerrit'  [Y/n]? Y

Location of Git repositories   [git]: 敲回车

Database server type           [h2/?]: mysql

Gerrit Code Review is not shipped with MySQL Connector/J 5.1.21

**  This library is required for your configuration. **

Download and install it now [Y/n]? Y

Server hostname                [localhost]: 敲回车

Server port                    [(mysql default)]: 敲回车

Database name                  [reviewdb]: 敲回车

Database username              [gerrit2]: 敲回车

gerrit2's password:输入数据库设置的密码

confirm password:输入数据库设置的密码

Type                           [LUCENE/?]: 敲回车

Authentication method          [OPENID/?]:http

Get username from custom HTTP header [y/N]?N

SSO logout URL                 : 敲回车

Install Verified label         [y/N]?Y

SMTP server hostname           [localhost]:如smtp.126.com

SMTP server port               [(default)]: 敲回车

SMTP encryption                [NONE/?]: 敲回车

SMTP username                  :输入邮箱账号

Run as                         [gerrit2]: 敲回车

Java runtime                 [/usr/lib/jvm/java-7-openjdk-i386/jre]: 敲回车

Copy gerrit-2.10.war to /home/gerrit2/gerrit/bin/gerrit.war [Y/n]? 敲回车

Listen on address              [*]: 敲回车

Listen on port                 [29418]: 敲回车

Gerrit Code Review is not shipped with Bouncy Castle Crypto SSL v149

  If available, Gerrit can take advantage of features

  in the library, but will also function without it.

Download and install it now [Y/n]?Y

Gerrit Code Review is not shipped with Bouncy Castle Crypto Provider v149

** This library is required by Bouncy Castle Crypto SSL v149. **

Download and install it now [Y/n]?Y

Behind reverse proxy           [y/N]?y

Proxy uses SSL (https://)      [y/N]?y

Subdirectory on proxy server   [/]: 敲回车

Listen on address              [*]: 敲回车

Listen on port                 [8081]:

Canonical URL                  [http://xxx/]:http://x.x.x.x:8081/

Install plugin commit-message-length-validator version v2.10 [y/N]?y

Install plugin download-commands version v2.10 [y/N]?y

Install plugin replication version v2.10 [y/N]?y

Install plugin reviewnotes version v2.10 [y/N]?y

Install plugin singleusergroup version v2.10 [y/N]?y

step7:若想对gerrit配置文件进行重新配置,则我们可以对/home/gerrit2/gerrit/etc/gerrit.conf文件进行配置,该配置文件如下所示,如果安装的时候已配置OK,则跳过次步骤

[gerrit]

        basePath = git

        canonicalWebUrl = http://x.x.x.x:8081/

[database]

        type = mysql

        hostname = localhost

        database = reviewdb

        username = gerrit2

[index]

        type = LUCENE

[auth]

        type = HTTP

[sendemail]

        smtpServer = localhost

[container]

        user = gerrit2

        javaHome = /usr/lib/jvm/java-7-openjdk-i386/jre

[sshd]

        listenAddress = x.x.x.x:29418

[httpd]

        listenUrl = proxy-http://x.x.x.x:8081/

[cache]

        directory = cache

step8:重新启动gerrit

/home/gerrit2/gerrit/bin/gerrit.sh restart

step9:配置apache2的登录密码

sudo touch /home/gerrit2/pwd

sudo htpasswd /home/gerrit2/pwd 账号

step10:在浏览器中输入http://x.x.x.x:8080即可以访问gerrit页面

猜你喜欢

转载自my.oschina.net/sfshine/blog/1814871
今日推荐