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 OpenGrok On Ubuntu Linux 【转】

原帖: Installing OpenGrok On ...
  • lifei_wyjw
  • lifei_wyjw
  • 2011年05月12日 11:04
  • 195


注:YOUDIR为自己设定的存放目录,这个大家随意哈。 第一步,安装Web服务器-Tomcat: 1、使用以下命令解压下载的Tomcat压缩包 #tar   xvzf   apache-tomca...
  • vfp8341
  • vfp8341
  • 2016年08月12日 12:25
  • 1475


为什么需要OpenGrok如何快速的搜索代码或文件? 如何快速的实现代码跳转以方便阅读?有很多方法,比如linux命令的方式实现检索,source insight等工具实现代码的跳转和阅读。但对于大...
  • thdsea4
  • thdsea4
  • 2017年10月12日 16:24
  • 354

懒人搭建OpenGrok for Android N on Ubuntu 16.04

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

ubuntu 14.04 opengrok安装及配置

参考官网: 1. 下载stable 版本
  • duanlina
  • duanlina
  • 2016年08月22日 15:56
  • 1442


OpenGrok 简单安装配置说明
  • hhcjb
  • hhcjb
  • 2014年05月12日 21:50
  • 5738


OpenGrok是一个快速,便于使用的源码搜索引擎与对照引擎,它能够帮助我们快速的搜索、定位、对照代码树。接下来就具体讲解一下OpenGrok的安装及使用。 安装Web服务器-Tomcat 第一步...
  • Tyronne
  • Tyronne
  • 2014年06月26日 23:53
  • 3824


sudo apt-get install exuberant-ctags tomcat8 apt-file list tomcat查看tomcat安装 启动tomcat bin/下 ./start...
  • ProgramResearch
  • ProgramResearch
  • 2015年10月07日 15:18
  • 214


CSDN GitHub Ubuntu搭建OpenGrok环境阅读Linux内核源代码 AderXCoding/system/tools/opengrok 本作品采用知识共享署名-非商业性使...
  • gatieme
  • gatieme
  • 2016年11月08日 16:42
  • 2370


ubuntu install opengrok 总结: 1. 安装jdk和tomcat
  • goodwillyang
  • goodwillyang
  • 2015年07月28日 17:44
  • 624
您举报文章:Installing OpenGrok On Ubuntu Linux 【转】