Installing OpenGrok On Ubuntu Linux 【转】

原创 2011年01月18日 13:04:00



Installing OpenGrok On Ubuntu Linux

I am really impressed with OpenGrok , a web-based source code search engine that I've found while I was trying to look up OpenJDK's source code. It is pretty cool as OpenGrok allows you to point your browser into an exact line of source code in your respository, allowing citations directly for discussion using hyperlinks, rather than cutting and pasting chunks of code. I find useful for annotating code, like when I'm using a wiki in conjunction with it to document design considerations for the source.

I'm only supplementing OpenGrok documentation because there were some parts of it which were less clear, taking longer than I expected to get it running. Hopefully, these instructions will help you cut down your setup time.

The assumption is that you're installing from a bare-bones Ubuntu system, and all commands here assume that you are root , which if you're like me, coming from a Gentoo background and sick of typing sudo all the time, you stay rooted all the time by using:

sudo -i

The next thing to do is to get all the relevant software via aptitude. I'll be using Apache Tomcat as my application server:

aptitude install sun-java6-jdk tomcat5.5 exuberant-ctags

Before we set up OpenGrok, we need to create the directory structure to store the files. For the sake of brevity, I'll use the same directory structure from OpenGrok's EXAMPLE.txt :


|-- bin

|-- data

`-- source

Download the tar.gz archive from its website , unpack and extract it. Copy the OpenGrok binaries into the /opengrok/bin :

# cp -r opengrok.jar lib /opengrok/bin

Edit and setup up the following parameters:




Note that I have put in the default location for the installed ctags for Ubuntu, you may have different locations/application names depending on your Linux distro. You'll then have to configure the web application. Go to the directory where you've downloaded your files, and unzip source.war to make modifications:

# mkdir source

# cd source

# unzip /path/to/opengrok-release/source.war

And make changes into WEB-INF/web.xml . The completed changes look like this:




<description>REQUIRED: Full path of the directory where data files generated by OpenGrok are stored</description>





<description>REQUIRED: Full path to source tree</description>





<description>Set this variable to true if you would like the web application to scan for external repositories (Mercurial)</description>


The text coloured red are the parts where you need to make modifications. The tags in blue indicate where the XML has originally been commented out by <!-- and --> you'll have to take them away.

Once that's done, you'll have to rezip the .war file back in place, and put it into Tomcat's webapps directory:

# zip -r source.war ./

# mv source.war /usr/share/tomcat5.5/webapps

After which, we'll need to configure our source code for OpenGrok to use, and set it up:

# cd /opengrok/source

# cp -r /your/source/code/ .

# java -Xmx1524m -jar opengrok.jar -W /opengrok/configuration.xml -P -S -v -s /opengrok/source -d /opengrok/data

This will generate the list of indices that allows OpenGrok to cross reference your source code. With that done, the final task is to setup Tomcat so that it has correct privileges. Append the following lines to /etc/tomcat5.5/04webapps.policy :

grant codeBase "file:${catalina.home}/webapps/source/-" {



grant codeBase "file:${catalina.home}/webapps/source/WEB-INF/lib/-" {



I'm just being cavalier here by giving full security access to OpenGrok, which should be safe. But I only doing it given because my application is firewalled from the outside world, so do make your own security adjustments appropriately ! Once that's done, restart Tomcat:

# /etc/init.d/tomcat5.5 restart

You should now have a functioning own OpenGrok respository to play with! However if you get an error with the stack trace showing Apache Lucene not being able to create a file, grant full permissions to the data directory:

# chmod -R 777 /opengrok/data/



java.lang.UnsupportedClassVersionError: Bad version number in .class file






Installing Django on an Ubuntu Linux Server

Installing Django on an Ubuntu Linux Server Today I had the task of installing a development ...
  • alaclp
  • alaclp
  • 2012年07月21日 00:45
  • 830

Installing MIT Scratch 2.0 on Ubuntu Linux 64 bits

参考连接:  我使用这种方法:ubuntu12.04(amd64) 下安装scrat...

Installing Hadoop on Windows / Linux / MAC(转)

转自 主要解决了

Installing STLinux on Ubuntu

  • 2013年07月14日 13:25
  • 27KB
  • 下载

installing samba on ubuntu

  • 2010年03月08日 10:33
  • 1KB
  • 下载

懒人搭建OpenGrok for Android N on Ubuntu 16.04

本文以在Ubuntu 16.04上对Anroid N的源代码配置OpenGrok为例,记录了适合像我这种懒人的最基本搭建过程。想用各种高级用法请自行参见官方文档。...

Installing Zend Server Community Edition (CE) on Ubuntu 10.04.3 LTS

Posted on September 7, 2011 by tommie Looking for a fast, reliable and easy PHP stack on ...
  • alaclp
  • alaclp
  • 2012年07月21日 10:45
  • 725

Installing Ubuntu 14.04 on a Pre-Installed Windows 8 (64-bit) System (UEFI Supported)

Useful Links: Install Ubuntu 14.04 alongside Windows 8.1 in 10 easy steps教程:Ubuntu 14.04 和 Windows ...
  • orzorz
  • orzorz
  • 2014年12月14日 08:55
  • 1106

【安装Hadoop 2.3 集群】Installing Hadoop 2.3.0 multi-node cluster on Ubuntu 13.10

Installing Hadoop 2.3.0 multi-node cluster on Ubuntu 13.10 【】 Make sure you have Oracle JDK 7 ...
  • nisxiya
  • nisxiya
  • 2014年09月02日 21:42
  • 746

Installing Odoo 9 on Ubuntu 14.04

Hi guys, 1. Introduction In this tutorial I will learn you how to install Odoo 9 on Ubuntu 14....
您举报文章:Installing OpenGrok On Ubuntu Linux 【转】