Gerrit review Server SETUP tutorial (Ubuntu 12.10)

Source: Internet
Author: User
Tags openid

//************************************** ********

You are welcome to repost it. Please indicate the source. Please respect the author!

Http://blog.csdn.net/airk000

Email: airk908@gmail.com

//************************************** ********

This article will detail how to install and configure the Gerrit server in a brand new Ubuntu system.

1. Install ubuntu12.xx (I am using 12.10, other versions are not tested)

2. Configure the Java environment

Download the jdk-6u34-linux-x64.bin (Baidu Google), run the installation in the terminal (if there is no permission, execute chmod A + x jdk-6u34-linux-x64.bin)

$:./Jdk-6u34-linux-x64.bin

The installation is automatically executed. After installation, configure related environment variables

$: Vim ~ /. Bashrc

Add the following environment variable: (username is your user name)

JAVA_HOME=/home/username/jdk1.6.0_34export JRE_HOME=$JAVA_HOME/jreexport CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATHexport PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

$: Source ~ /. Bashrc

Verify whether the configuration is successful:

$: Java-version

$: Javac

If no error is returned for the above terminal commands and the normal version information and help information are available, the Java environment configuration is successful and you can continue. If any error occurs, Baidu and Google.

3. Configure Gerrit. XXX. War

Install git before configuration.

$: Sudo apt-Get install git

Open the terminal and go to the directory where Gerrit. XXX. War is located. Run the following command:

$: Java-jar Gerrit. XXX. War init-D review_site

Create '/home/username/review_site' [Y/n]?

...

Basically, you can press enter all the way. The default configuration is good. One thing you need to talk about is the authentication method openid. openid can be used to log on to Google or Yahoo Mail, but in some cases due to GFW, these may be difficult to use, so you can select HTTP (recommended ). The managed database type varies from person to person. The default value is H2.

After the configuration is complete, the Gerrit. Sh script will be automatically called to start the Gerrit service and the browser will be opened automatically. At this time, it must fail because apache2.

Before configuring apache2, you must make minor changes to the Gerrit configuration file, which is review_site/etc/Gerrit. config.

Change canonicalweburl under field [Gerrit] To https: // 127.0.0.1: 8081/

Change listenurl under field [httpd] to proxy-https: // 127.0.0.1: 8081/

Save it.

4. Configure apache2

Terminal execution:

$: Sudo apt-Get install apache2

Will be installed, just a little wait. In addition, I am using a 163 image software source, and I feel that the speed is still very good.

After installing apache2 on Ubuntu, there is no httpd. conf configuration file. Go to/etc/apache2/to check whether the configuration file is correct.

Create the httpd. conf file (of course, root permission is required) and enter the following content:

<VirtualHost *>        ServerName localhost        ProxyRequests Off        ProxyVia Off        ProxyPreserveHost On        <Proxy *>                Order deny,allow                Allow from all        </Proxy>        <Location /login/>                AuthType Basic                AuthName "Gerrit Code Review"                AuthBasicProvider file                AuthUserFile /home/username/review_site/etc/passwords                Require valid-user        </Location>        ProxyPass / http://127.0.0.1:8081/</VirtualHost>

This configuration file means that when accessing any (*), proxy is performed to the/login/directory, and the user name and password are requested according to authuserfile. The final proxy is http: // 127.0.0.1: 8081/

There are two key points to consider:

A. About review_site/etc/passwords

Open the terminal, go to the review_site/etc directory, and execute:

$: Touch passwords

$: Htpasswd passwords Gerrit

You will be requested to enter the password of this user (Gerrit). After confirmation, the relevant information will be written into the passwords file. This user name and password are required for accessing the local Gerrit server later.

B. proxypass/http: // 127.0.0.1: 8081/

It must be the same as the configuration of the [httpd] field in Gerrit. config.

Save the file after configuration.

Don't be too happy. It's not over yet. Now this configuration file is just written and has not taken effect. Open apache2.conf.

You will find that the apache2.conf file references other configuration files through include, but there is no httpd. conf file. Refer to other include files to reference httpd. conf.

Include httpd. conf

Save and exit.

No.

If you are in a hurry to restart the apache2 service, you will find a proxy error. The reason is that the proxy module of apache2 has not been enabled. You can view apache2.conf to find that the module under the "mod-enable" folder is referenced, but no proxy module is found here, this vulnerability is found in the mod-available. Through LS-L, it is found that all functions under enable are linked. OK, link it.

Use the Ln-s command to link proxy. conf proxy. Load proxy_http.load from available to enable.

Success: Execute:

$: Sudo/etc/init. d/apache2 restart

Restart the apache2 service.

Open the server and log on to 127.0.0.1. The Gerrit page is displayed.

Over.

PS: Common Errors

1. the reference of apache2.conf has not been modified, so httpd. conf does not take effect.

2. After the virtualhost field in httpd. conf is written as *, it is the same as 127.0.0.1: 8081. here it means the input, followed by the port "to" of the proxy.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.