Setting Up OpenGrok on a Linux System

  1. Install ctags dependencies
sudo apt install autoconf automake
  1. Clone the universal-ctags repository
git clone https://github.com/universal-ctags/ctags.git
  1. Compile and install ctags
cd ctags
./autogen.sh
./configure
make
sudo make install

Note: If the installation fails, you can copy the binary version of ctags to /usr/local/bin. 5. Download and extract the latest Tomcat core

tar -xvf apache-tomcat-9.0.53.tar.gz
  1. Start Tomcat (use shutdown.sh to stop it)
sh apache-tomcat-9.0.53/bin/startup.sh
  1. Open your browser and go to http://localhost:8080 8. Download and extract the latest OpenGrok release from GitHub
tar -xvf opengrok-1.3.16.tar.gz
  1. Copy the source.war file to the Tomcat webapps directory
cp opengrok-1.3.16/lib/source.war apache-tomcat-9.0.53/webapps/
  1. Set up environment variables
sudo vi ~/.bashrc
# Add the following lines
export JAVA_HOME=/usr
export OPENGROK_TOMCAT_BASE=/home/user/app/opengrok/apache-tomcat-9.0.53
export CATALINA_HOME=/home/user/app/opengrok/apache-tomcat-9.0.53
export OPENGROK_APP_SERVER=Tomcat
export OPENGROK_INSTANCE_BASE=/home/user/app/opengrok/opengrok-1.3.16
export LANG=zh_CN.UTF-8

  1. Aply the environment variables
source ~/.bashrc
  1. Create necessary directories
mkdir -p opengrok-1.3.16/{etc,src,data,history}
  1. Copy or link your source code to the src directory
cp -r /path/to/your/code opengrok-1.3.16/src/  # or ln -s /path/to/your/code opengrok-1.3.16/src/your_code
  1. Gneerate the index (re-run this command after any updates in the src directory)
java -jar opengrok-1.3.16/lib/opengrok.jar -P -S -v -s opengrok-1.3.16/src -d opengrok-1.3.16/data -H --repository opengrok-1.3.16/history -W opengrok-1.3.16/etc/configuration.xml
  1. Modify the actual configuration path in web.xml
gedit apache-tomcat-9.0.53/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/user/app/opengrok/opengrok-1.3.16/etc/configuration.xml</param-value>
</context-param>

  1. Open the website at http://localhost:8085/source/ 17. If there is a port conflict, modify the ports in server.xml
sudo cat conf/server.xml
<Server port="8006" shutdown="SHUTDOWN">

<Connector port="8085" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443"
               address="127.0.0.1" />

<Connector protocol="AJP/1.3"
               address="::1"
               port="8010"
               redirectPort="8443" />

  1. Restart Tomcat and open the webpage
sh apache-tomcat-9.0.53/bin/shutdown.sh && sh apache-tomcat-9.0.53/bin/startup.sh

Tags: OpenGrok Tomcat ctags java apache

Posted on Wed, 02 Sep 2026 16:09:58 +0000 by Gabriel_Haukness