Settup OpenGrok in Ubuntu 18.4

1. Install universal-ctags

Install git and autoconf if not yet

sudo apt install git autoconf

Download ctags source code and compile it

# cd to the location you want to install ctags, e.g. /opt
git clone https://github.com/universal-ctags/ctags.git
cd /opt/ctags
./autogen.sh
./configure
make
# When build complete, try the  new ctags command
cd ctags
./ctags --version
sudo make install

2. Install the default JRE/JDK

The easiest option for installing Java is to use the version packaged with Ubuntu. By default, Ubuntu 18.04 includes Open JDK, which is an open-source variant of the JRE and JDK.
After Sep.2018, the default version is OpenJDK 11.

Check if JAVA is already installed

sudo apt update
java -version

If Java is not currently installed, you’ll see the following output:

Command 'java' not found, but can be installed with:

apt install default-jre
apt install openjdk-11-jre-headless
apt install openjdk-8-jre-headless
apt install openjdk-9-jre-headless

Install default JAVA

Run following command to install default JAVA

$ sudo apt install default-jre

After installation, run ‘java -version’ you will see:

openjdk version "11.0.6" 2020-01-14
OpenJDK Runtime Environment (build 11.0.6+10-post-Ubuntu-1ubuntu118.04.1)
OpenJDK 64-Bit Server VM (build 11.0.6+10-post-Ubuntu-1ubuntu118.04.1, mixed mode, sharing)

JDK is installed under /usr/lib/jvm, cd to here to check the default-java is pointing to the latest version

sliu@sliu-MS-7B84:/usr/lib/jvm$ ls -alt
total 28
drwxr-xr-x   2 root root 4096 Mar  9 14:48 openjdk-11
drwxr-xr-x   5 root root 4096 Mar  9 14:48 .
drwxr-xr-x   9 root root 4096 Mar  9 14:48 java-11-openjdk-amd64
drwxr-xr-x 136 root root 4096 Mar  3 13:24 ..
lrwxrwxrwx   1 root root   21 Jan 15 07:14 java-1.11.0-openjdk-amd64 -> java-11-openjdk-amd64
-rw-r--r--   1 root root 2044 Jan 15 07:14 .java-1.11.0-openjdk-amd64.jinfo
lrwxrwxrwx   1 root root   25 Feb 20  2019 default-java -> java-1.11.0-openjdk-amd64

Install Tom Cat web server

Information page:

How to Install Apache Tomcat 9 on Ubuntu 18.04 & 16.04 LTS
https://tecadmin.net/install-tomcat-9-on-ubuntu/

Download and Installation

sliu@sliu-MS-7B84:~/Download$
wget https://downloads.apache.org/tomcat/tomcat-9/v9.0.31/bin/apache-tomcat-9.0.31.tar.gz
For latest version:
wget https://downloads.apache.org/tomcat/tomcat-9/v9.0.56/bin/apache-tomcat-9.0.56.tar.gz
tar -zxvf apache-tomcat-9.0.31.tar.gz
sudo mv apache-tomcat-9.0.31 /usr/local/tomcat9

Setup TomCat env

echo "export CATALINA_HOME="/usr/local/tomcat9"" >> ~/.bashrc
echo "export JAVA_HOME="/usr/lib/jvm/default-java"" >> ~/.bashrc
echo "export JRE_HOME="/usr/lib/jvm/defalt-java"" >> ~/.bashrc

Verify Tom Cat

source .bashrc
cd /usr/local/tomcat9/
cd bin
./startup.sh

From web browser type: http://127.0.0.1:8080/
You will see TomCat Home page, done!

Download and Install opengrok-1.3.9

At location where to insall opengrok

sliu@sliu-MS-7B84:/opt$ wget  https://github.com/oracle/opengrok/releases/download/1.3.9/opengrok-1.3.9.tar.gz
sliu@sliu-MS-7B84:/opt$ tar -zxvf opengrok-1.3.9.tar.gz
sliu@sliu-MS-7B84:/opt/opengrok-1.3.9$ mkdir etc data src

Index the source tree

Add projects to opengrok src dir

E.g. adding a “lexus-large” project

sliu@sliu-MS-7B84:/opt/opengrok-1.3.9/src$ mkdir lexus-large
sliu@sliu-MS-7B84:/opt/opengrok-1.3.9/src$ cd lexus-large/

From here checkout the src code

git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git kernel.v5.7-rc2

Index the source tree

Check command format and options:

java -Djava.util.logging.config.file=/home/sliu/Download/opengrok-1.3.9/doc/logging.properties -jar /home/sliu/Download/opengrok-1.3.9/lib/opengrok.jar

To index run:

sudo java -Djava.util.logging.config.file=/opt/opengrok-1.3.9/doc/logging.properties -jar /opt/opengrok-1.3.9/lib/opengrok.jar -s /opt/opengrok-1.3.9/src  -W /opt/opengrok-1.3.9/etc/configuration.xml -U http://localhost:8080/source -d /opt/opengrok-1.3.9/data -c ctags -m 1024 -H -P -S -G

Deploy to Tom Cat

Copy source.war to Tomcat

cp /home/sliu/Download/opengrok-1.3.9/lib/source.war  /usr/local/tomcat9/webapps/

Modify /usr/local/tomcat9/webapps/source/WEB-INF/web.xml

<display-name>OpenGrok</display-name>
    <description>A wicked fast source browser</description>
    <context-param>
        <description>Full path to the configuration file where OpenGrok can read its configuration</description>
        <param-name>CONFIGURATION</param-name>
        <param-value>/opt/opengrok-1.3.9/etc/configuration.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.opengrok.web.WebappListener</listener-class>
    </listener>
    <filter>

Restart tom cat after each re-index

cd /usr/local/tomcat9/bin
./shutdown.sh
./startup.sh

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值