Gerrit on Debian

## How to build the package

* First make sure you have **build-essential** package installed on your system.
* Clone the package repository for [gerrit-debian](https://github.com/dnaeon/gerrit-debian)

Now building the package is easy as executing the command below:

$ cd /usr/local/src

$ git clone https://github.com/dnaeon/gerrit-debian.git

$ dpkg-buildpackage -us -uc

$ cd gerrit-debian

In this how to I want to use MySQL, so;

$ sudo apt-get install mysql-server mysql-client

 

Configure MySQL before start configuration:

CREATE USER 'gerrit'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON gerrit.* TO 'gerrit'@'localhost';
CREATE database gerrit;

$ sudo dpkg -i gerrit_2.4.2_all.deb

Configure Gerrit authentication is just a pain in the ass, to make thinks easy and secure I will use Apache Web Server as proxy, this way I can get more control about the whole thing.


HTTP-Client  <---> 80/443:Apache Web Server <---> 8081:Gerrit

#Gerrit configuration

cat /var/lib/gerrit/review_site/etc/gerrit.config

[gerrit]
basePath = git
canonicalWebUrl = http://git.mxt.com.br/gerrit/
[database]
type = MYSQL
hostname = localhost
database = gerrit
username = gerrit
[auth]
type = HTTP
[sendemail]
smtpServer = mail.maxtrack.com.br
smtpUser = gerrit
[container]
user = gerrit
javaHome = /usr/lib/jvm/java-6-openjdk-amd64/jre
[sshd]
listenAddress = 192.168.3.222:29418
[httpd]
listenUrl = proxy-http://127.0.0.1:8081/gerrit/
[cache]
directory = cache

Apache configuration

$cat /etc/apache2/sites-enabled/gerrit

<VirtualHost *:80>
ServerName hostname.com.br
ProxyRequests Off
ProxyVia Off
ProxyPreserveHost On

<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location /gerrit/login/>
AuthType Basic
AuthName “Gerrit Code Review”
Require valid-user
AuthUserFile ‘/etc/apache2/gerrit.htpasswd’
</Location>

ProxyPass /gerrit/ http://127.0.0.1:8081/gerrit/
ProxyPassReverse /gerrit/ http://127.0.0.1:8081/gerrit/
</VirtualHost>

 

 

cat /etc/apache2/sites-enabled/gerrit-ssl
<IfModule mod_ssl.c>
<VirtualHost git.mxt.com.br:443>
ServerName git.mxt.com.br
ServerAdmin hamilton@maxtrack.com.br
ProxyRequests Off
ProxyVia Off
ProxyPreserveHost On

<Proxy *>

Order deny,allow
Allow from all
</Proxy>
<Location /gerrit/login/>
AuthType Basic
AuthName “Gerrit Code Review”
Require valid-user
AuthUserFile ‘/etc/apache2/gerrit.htpasswd’
</Location>
ProxyPass /gerrit/ http://127.0.0.1:8081/gerrit/
ProxyPassReverse /gerrit/ http://127.0.0.1:8081/gerrit/
# SSL Engine Switch:
# Enable/Disable SSL for this virtual host.
SSLEngine on

SSLCertificateFile /etc/apache2/ssl/gerrit.crt
SSLCertificateKeyFile /etc/apache2/ssl/gerrit.key

BrowserMatch “MSIE [2-6]” \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
# MSIE 7 and newer should be able to use keepalive
BrowserMatch “MSIE [17-9]” ssl-unclean-shutdown

</VirtualHost>
</IfModule>

 

The following site has amazing information:

http://dachary.org/?p=1716
  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: