Installing OpenGrok On Ubuntu Linux 【转】

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

 

原帖:http://blog.vinceliu.com/2008/06/installing-opengrok-on-ubuntu-linux.html

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 :



/opengrok

|-- 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 run.sh opengrok.jar lib /opengrok/bin



Edit run.sh and setup up the following parameters:



SRC_ROOT=/opengrok/source

DATA_ROOT=/opengrok/data

EXUB_CTAGS=/usr/bin/ctags



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:



<context-param>


<param-name>DATA_ROOT</param-name>

<param-value>/opengrok/data
</param-value>

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

</context-param>



<context-param>

<param-name>SRC_ROOT</param-name>

<param-value>/opengrok/src
</param-value>

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

</context-param>



<context-param>

<param-name>SCAN_REPOS</param-name>

<param-value>false</param-value>

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

</context-param>




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/-" {

permission java.security.AllPermission;

};



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

permission java.security.AllPermission;

};



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/

注:

如果在同一台服务器上装有不同版本的JDK,可能导致以下错误:

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

解决方法:

 

指定正确的JAVA_HOME(与需求的jdk版本一致),然后重启tomcat。

 

 

Installing OpenGrok On Ubuntu Linux 【转】

原帖:http://blog.vinceliu.com/2008/06/installing-opengrok-on-ubuntu-linux.html Installing OpenGrok On ...
  • lifei_wyjw
  • lifei_wyjw
  • 2011年05月12日 11:04
  • 195

Ubuntu环境下OpenGrok的安装及配置

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

在Ubuntu下搭建OpenGrok

为什么需要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安装及配置

参考官网:http://opengrok.github.io/OpenGrok/ 1. 下载stable 版本      https://github.com/OpenGrok/OpenGrok/fi...
  • duanlina
  • duanlina
  • 2016年08月22日 15:56
  • 1442

Linux下Opengrok安装部署与使用

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

Ubuntu下OpenGrok的安装配置

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

Ubuntu下OpenGrok安装使用

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

Ubuntu搭建OpenGrok环境阅读Linux内核源代码

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

ubuntu14上安装opengrok

ubuntu install opengrok 总结: 1. 安装jdk和tomcat https://www.digitalocean.com/community/tutorials/...
  • goodwillyang
  • goodwillyang
  • 2015年07月28日 17:44
  • 624
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Installing OpenGrok On Ubuntu Linux 【转】
举报原因:
原因补充:

(最多只允许输入30个字)