October 21, 2021
How to install Solr on Ubunt 20.04 LTS

How To Install Apache Solr 8.9 On Ubuntu 20.04 LTS

On this article we will learn how to install Apache Solr version 8.9.0 on Ubuntu 20.04 LTS operating system.


Apache Solr is widely used for enterprise search and analytics use cases and has an active development community and regular releases. Solr was developed at CNET Networks as an in-house project to add search capability for the company website. The major features of Apache Solr including : full-text search, hit highlighting, faceted search, real-time indexing, dynamic clustering, database integration, NoSQL features and rich document handling. Apache Solr is written in Java. Solr is designed for scalability and fault tolerance. Apache Solr version 8.9.0 is the most recent Apache Solr release. On this article we will learn how to install Apache Solr 8.9 on Ubuntu 20.04 LTS.

Apache Solr Installaton on Ubuntu 20.04 LTS

Apache Solr 8.9.0 installation on Ubuntu 20.04 LTS operating system will be explained in several sections below.

  1. Prerequisite
  2. Installing Java
  3. Installing Solr on Ubuntu
  4. Manage Solr Service
  5. Creating Collection in Solr
  6. Accessing Solr Admin Panel

1. Prerequisite

  • Ubuntu 20.04 LTS system
  • User account with sudo privillege
  • Sufficient disk space and good network to access Apache Solr source
  • Updated system with the last package

By updating our system, it will refresh the local list of available packages software to the newer stable version. To update Ubuntu 20.04 system repositories, we will use the command line : sudo dnf update.

ramansah@app01:~$ sudo apt update
[sudo] password for ramansah: 
Hit:1 https://download.docker.com/linux/ubuntu focal InRelease
Hit:2 https://dl.winehq.org/wine-builds/ubuntu focal InRelease                                  
Get:4 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]                       
Hit:6 http://us.archive.ubuntu.com/ubuntu focal InRelease                                       
Get:8 http://us.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]                      
Hit:9 http://apt.postgresql.org/pub/repos/apt focal-pgdg InRelease                              
Get:10 http://security.ubuntu.com/ubuntu focal-security/main i386 Packages [275 kB]
Hit:3 https://downloads.mariadb.com/MariaDB/mariadb-10.5/repo/ubuntu focal InRelease     

2. Installing Java

We will check whether java is installed on our system, if not, then we will install java.

ramansah@app01:~$ java -version

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

sudo apt install default-jre              # version 2:1.11-72, or
sudo apt install openjdk-11-jre-headless  # version 11.0.11+9-0ubuntu2~20.04
sudo apt install openjdk-16-jre-headless  # version 16.0.1+9-1~20.04
sudo apt install openjdk-8-jre-headless   # version 8u292-b10-0ubuntu1~20.04
sudo apt install openjdk-13-jre-headless  # version 13.0.7+5-0ubuntu1~20.04

Because java has not been installed on our system, we will first install java using the command line:

ramansah@app01:~$ sudo apt install openjdk-11-jre-headless
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  dbconfig-common gsfonts imagemagick-6-common libaio1 libcgi-fast-perl libcgi-pm-perl libdbi-perl
  libfcgi-perl libfftw3-double3 libfprint-2-tod1 libhtml-template-perl libjs-chart.js
  libjs-jquery-ui libjs-raphael liblqr-1-0 libmagickcore-6.q16-6 libreadline5 libterm-readkey-perl
  ruby-actioncable ruby-actionmailer ruby-actionpack ruby-actionpack-action-caching
  ruby-actionpack-xml-parser ruby-actionview ruby-activejob ruby-activemodel ruby-activerecord
  ruby-activestorage ruby-activesupport ruby-addressable ruby-arel ruby-atomic ruby-builder
  ruby-bundler ruby-coderay ruby-concurrent ruby-crass ruby-css-parser ruby-erubi
  ruby-eventmachine ruby-globalid ruby-hike ruby-htmlentities ruby-i18n ruby-jquery-rails
  ruby-loofah ruby-mail ruby-marcel ruby-method-source ruby-mime-types ruby-mime-types-data
  ruby-mimemagic ruby-mini-mime ruby-molinillo ruby-multi-json ruby-mysql2
  ruby-net-http-persistent ruby-net-ldap ruby-nio4r ruby-nokogiri ruby-oj ruby-pkg-config
  ruby-public-suffix ruby-rack-test ruby-rails ruby-rails-deprecated-sanitizer
  ruby-rails-dom-testing ruby-rails-html-sanitizer ruby-rails-observers ruby-railties ruby-rbpdf
  ruby-rbpdf-font ruby-redcarpet ruby-request-store ruby-rmagick ruby-roadie ruby-roadie-rails
  ruby-rouge ruby-sprockets ruby-sprockets-rails ruby-thor ruby-thread-safe ruby-tilt ruby-tzinfo
  ruby-websocket-driver ruby-websocket-extensions socat
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  ca-certificates-java java-common
Suggested packages:
  default-jre fonts-dejavu-extra fonts-ipafont-gothic fonts-ipafont-mincho fonts-wqy-microhei
  | fonts-wqy-zenhei
The following NEW packages will be installed:
  ca-certificates-java java-common openjdk-11-jre-headless
0 upgraded, 3 newly installed, 0 to remove and 140 not upgraded.
Need to get 37.3 MB of archives.
After this operation, 171 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y

3. Installing Solr

On this section, we will download, extract and install Solr. The lastest version of Apache Solr when this article created is version 8.9.0.

3.1. Download Apache Solr

We are going to use /opt dirctory to hold Apache package system.

ramansah@app01:/opt$ sudo wget https://downloads.apache.org/lucene/solr/8.9.0/solr-8.9.0.tgz
--2021-08-31 11:53:59--  https://downloads.apache.org/lucene/solr/8.9.0/solr-8.9.0.tgz
Resolving downloads.apache.org (downloads.apache.org)...,,, ...
Connecting to downloads.apache.org (downloads.apache.org)||:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 202942547 (194M) [application/x-gzip]
Saving to: ‘solr-8.9.0.tgz’

solr-8.9.0.tgz             100%[========================================>] 193.54M   834KB/s    in 4m 4s   

2021-08-31 11:58:04 (811 KB/s) - ‘solr-8.9.0.tgz’ saved [202942547/202942547]

3.2. Extract Apache Solr 8.9.0

ramansah@app01:/opt$ sudo tar xzf solr-8.9.0.tgz solr-8.9.0/bin/install_solr_service.sh --strip-components=2 
ramansah@app01:/opt$ ls -ltr
total 198212
drwxr-xr-x 6 root root      4096 Feb 23  2021 wine-stable
-rwxr-xr-x 1 root root     12694 Jun 10 13:23 install_solr_service.sh
-rw-r--r-- 1 root root 202942547 Jun 10 18:16 solr-8.9.0.tgz
ramansah@app01:/opt$ sudo bash solr-8.8.1/bin/install_solr_service.sh solr-8.9.0.tgz 

3.4. Install Apache Solr on Ubuntu 20.04

ramansah@app01:/opt$ sudo bash ./install_solr_service.sh solr-8.9.0.tgz 
id: ‘solr’: no such user
Creating new user: solr
Adding system user `solr' (UID 127) ...
Adding new group `solr' (GID 134) ...
Adding new user `solr' (UID 127) with group `solr' ...
Creating home directory `/var/solr' ...

Extracting solr-8.9.0.tgz to /opt

Installing symlink /opt/solr -> /opt/solr-8.9.0 ...

Installing /etc/init.d/solr script ...

Installing /etc/default/solr.in.sh ...

Service solr installed.

4. Managing Apache Solr Service

By default the Apache Solr service will be activated immediately after the installation process is complete. To make sure we will stop service and startig up it again.

ramansah@app01:/opt$ sudo systemctl stop solr
ramansah@app01:/opt$ sudo systemctl start solr
ramansah@app01:/opt$ sudo systemctl status solr
● solr.service - LSB: Controls Apache Solr as a Service
     Loaded: loaded (/etc/init.d/solr; generated)
     Active: active (exited) since Tue 2021-08-31 12:18:31 PDT; 8s ago
       Docs: man:systemd-sysv-generator(8)
    Process: 8592 ExecStart=/etc/init.d/solr start (code=exited, status=0/SUCCESS)

Aug 31 12:18:27 app01.otodiginet.com systemd[1]: Starting LSB: Controls Apache Solr as a Service...
Aug 31 12:18:27 app01.otodiginet.com su[8594]: (to solr) root on none
Aug 31 12:18:27 app01.otodiginet.com su[8594]: pam_unix(su-l:session): session opened for user solr by (uid=0)
Aug 31 12:18:31 app01.otodiginet.com solr[8649]: Started Solr server on port 8983 (pid=8643). Happy searching!
Aug 31 12:18:31 app01.otodiginet.com systemd[1]: Started LSB: Controls Apache Solr as a Service.
ramansah@app01:/opt$ sudo su - solr -c "/opt/solr/bin/solr create -c otodigicollection -n data_driven_schema_configs"

5. Creating Collection

The term ‘collection‘ on Apache Solr is the group of cores that together form a single logical index. A collection has a different set of configuration files and schema definitions than other collections. On our article, we will create a collection and named it as ‘otodigicollection‘. For this purpose we will submit the command line : sudo su - solr -c "/opt/solr/bin/solr create -c otodigicollection -n data_driven_schema_configs".

ramansah@app01:/opt$ sudo su - solr -c "/opt/solr/bin/solr create -c otodigicollection -n data_driven_schema_configs

6. Accessing Apache Solr Dashboard

By defautl Apache Solr dasboard will be avialable on URL : http://[ip_address_server|servername]:8983/solr.

Apache Solr Dasboard
Apache Solr Dasboard


We have shown you how to install Apache Solr version 8.9.0. on Ubunt 20.04 LTS. The installation process is quite simple.

Share this article via :

Leave a Reply

Your email address will not be published. Required fields are marked *