OpenGrok的安装和配置

一、简介

  OpenGrok is a fast and usable source code search and cross reference engine. It helps you search, cross-reference and navigate your source tree. It can understand various program file formats and version control histories like Mercurial, Git, SCCS, RCS, CVS, Subversion, Teamware, ClearCase, Perforce, Monotone and Bazaar. In other words it lets you grok (profoundly understand) the open source, hence the name OpenGrok. It is written in Java.

  (from:http://opengrok.github.io/OpenGrok)

 

  OpenGrok的Android系统源码搜索引擎:

  http://androidxref.com


二、下载安装相关软件

1. 安装Java,tomcat7

sudo apt-get install openjdk-7-jdk

sudo apt-get install tomcat7

  安装完成后打开浏览器,浏览http://192.168.108.130:8080,如果看到有页面出现,就说明Java和Tomcat安装成功了。

2. 安装exuberant-ctags

sudo apt-get install exuberant-ctags

3. 安装配置OpenGrok  

  官方安装教程:How-to-install-OpenGrok

 

  1)下载OpenGrok:

    http://opengrok.github.io/OpenGrok/

 

  2) 解压OpenGrok:

tar -zxvf opengrok-0.12.1.tar.gz

  3)修改OpenGrok配置:

vi ./bin/OpenGrok

    修改如下选项:

      a)修改OPENGROK_INSTANCE_BASE:

OPENGROK_INSTANCE_BASE="${OPENGROK_INSTANCE_BASE:-/home/napoleon/tools/opengrok-0.12.1}"

        红色部分为之后生成index的路径。

 

      b) 修改OPENGROK_WAR_TARGET_TOMCAT:

OPENGROK_WAR_TARGET_TOMCAT="${OPENGROK_WAR_TARGET_TOMCAT:-/var/lib/tomcat7/webapps}"

        红色部分为tomcat的webapps路径;

        如果默认安装tomcat,可以不用手动配置,OpenGrok会自动去搜索webapps目录。

 

      c) ./lib/source.war文件拷贝到/var/lib/tomcat7/webapps目录下:

./bin/OpenGrok deploy

         也可以手动拷贝:

cp ./lib/source.war /var/lib/tomcat7/webapps/

        在浏览器中打开http://192.168.108.130:8080/source,会在webapps目录下生成OpenGrok目录和相关配置文件。

      d) 建立索引:

 ./bin/OpenGrok index ./src/

        src/为源码存放的路径。

 

      e) 修改tomcat配置文件/var/lib/tomcat7/webapps/opengrok/WEB-INF/web.xml:      

  <context-param>
    <param-name>CONFIGURATION</param-name>
    <param-value>/home/napoleon/tools/opengrok-0.12.1/etc/configuration.xml</param-value>
    <description>Full path to the configuration file where OpenGrok can read it's configuration</description>
  </context-param>

        代码中红色部分为OpenGrok解压路径。

 

    在浏览器中打开http://192.168.108.130:8080/source,就可以查询和阅读src/目录下的代码了。

 

 Tip: 配置OpenGrok搜索页面提供下载源码(src/)的功能:把src/目录里的所有文件和目录复制到./data/raw/目录下即可。

      

      

    

 

posted on 2017-03-21 18:02  EastJason  阅读(665)  评论(0编辑  收藏  举报

导航