[[HOW TO]-ubuntu20.10安装openjrok指南

1. 安装jdk

sudo apt install openjdk-8-jdk

2. 安装Tomcat

(http://tomcat.apache.org/) tar -xvf apache-tomcat-9.0.37.tar.gz

3. 启动Tomcat(关闭Tomcat脚本是shutdonw.sh)

sh apache-tomcat-9.0.37/bin/startup.sh

4. 使用浏览器打开http://localhost:8080

5. 下载解压OpenGrok

https://oracle.github.io/opengrok/

tar -xvf opengrok-1.3.16.tar.gz

6. 复制source.war到Tomcat

cp opengrok-1.3.16/lib/source.war apache-tomcat-9.0.37/webapps/

7. 配置环境变量

sudo vi ~/.bashrc

opengrok

export JAVA_HOME=/usr export OPENGROK_TOMCAT_BASE=/home/test/program/opengrok/apache-tomcat-9.0.37 export CATALINA_HOME=/home/test/program/opengrok/apache-tomcat-9.0.37 export OPENGROK_APP_SERVER=Tomcat export OPENGROK_INSTANCE_BASE=/home/test/program/opengrok/opengrok-1.3.16 export LANG=zh_CN.gb2312

source ~/.bashrc

8. 创建目录

mkdir opengrok-1.3.16/etc opengrok-1.3.16/src opengrok-1.3.16/data

9. 将代码拷贝或软链接到src目录下

cp -r xxx opengrok-1.3.16/src/test # or ln -s dirpath dir_name

10. 生成索引(之后每次在src目录下有更新需要重新索引)

java -jar opengrok-1.3.16/lib/opengrok.jar -P -S -v -s opengrok-1.3.16/src -d opengrok-1.3.16/data -W opengrok-1.3.16/etc/configuration.xml

11. 修改实际configuration路径,将CONFIGURATION的value改成configuration.xml实际路径。

# sudo vi apache-tomcat-9.0.37/webapps/source/WEB-INF/web.xml 
<context-param>
    <description>Full path to the configuration file where OpenGrok can read its configuration</description>
    <param-name>CONFIGURATION</param-name>
    <param-value>/home/test/program/opengrok/opengrok-1.3.16/etc/configuration.xml</param-value>
</context-param>

12. 再次打开网站: http://localhost:8080/source/

经验分享 程序员 微信小程序 职场和发展