(Last Updated On: November 19, 2018)

Apache Solr is a highly scalable, reliable, and fault tolerant open-source search tool written in Java. Solr aims at providing distributed indexing, replication, and load-balanced querying with an automated failover and recovery.

Solr powers the search and navigation features of many of the world’s largest internet sites. In this guide, we will look at how to  Install Latest Apache Solr on Ubuntu 18.04 / Debian 9.

For CentOS 7 / Fedora refer to:

Install Latest Apache Solr on CentOS 7 / Fedora 29 / Fedora 28

Step 1: Install Java

Apache Solr requires Java to be installed. Install OpenJDK on Ubuntu 18.04 /16.04 / Debian 9 by using the guide on the link below:

How to Install Java 11 on Ubuntu 18.04 /16.04 / Debian 9

After the installation, confirm that you can run the javacommand from your terminal.

$ java -version
java version "11.0.1" 2018-10-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)

Step 2: Install Latest Apache Solr on Ubuntu 18.04 / Debian 9

Apache Solr is not available on Ubuntu & Debian upstream repositories, it need to be downloaded and installed manually. The releases of Apache Solr are available on the official website, check the link before saving the version to the LATEST_VERvariable.

export LATEST_VER="7.5.0"
curl -O https://www-eu.apache.org/dist/lucene/solr/${LATEST_VER}/solr-${LATEST_VER}.tgz

Extract the archive downloaded:

tar xvf solr-${LATEST_VER}.tgz

Now run the Apache Solr service installer script to setup Solr environment.

cd solr-${LATEST_VER}/bin/
./install_solr_service.sh ~/solr-${LATEST_VER}.tgz

Sample output:

id: 'solr': no such user
Creating new user: solr
Adding system user `solr' (UID 111) ...
Adding new group `solr' (GID 117) ...
Adding new user `solr' (UID 111) with group `solr' ...
Creating home directory `/var/solr' ...

Extracting /root/solr-7.5.0.tgz to /opt
Installing symlink /opt/solr -> /opt/solr-7.5.0 ...
Installing /etc/init.d/solr script ...
Installing /etc/default/solr.in.sh ...
Service solr installed.

The script will install and start Solr service. You can check the status by running:

$ sudo systemctl status solr
* solr.service - LSB: Controls Apache Solr as a Service
   Loaded: loaded (/etc/init.d/solr; generated)
   Active: active (exited) since Sun 2018-11-18 13:12:07 PST; 8min ago
     Docs: man:systemd-sysv-generator(8)
  Process: 2903 ExecStart=/etc/init.d/solr start (code=exited, status=0/SUCCESS)

Nov 18 13:12:00 ubuntu-01 solr[2903]: *** [WARN] *** Your open file limit is currently 1024.
Nov 18 13:12:00 ubuntu-01 solr[2903]:  It should be set to 65000 to avoid operational disruption.
Nov 18 13:12:00 ubuntu-01 solr[2903]:  If you no longer wish to see this warning, set SOLR_ULIMIT_CHECKS to false in your profile or solr.in.sh
Nov 18 13:12:00 ubuntu-01 solr[2903]: *** [WARN] ***  Your Max Processes Limit is currently 7732.
Nov 18 13:12:00 ubuntu-01 solr[2903]:  It should be set to 65000 to avoid operational disruption.
Nov 18 13:12:00 ubuntu-01 solr[2903]:  If you no longer wish to see this warning, set SOLR_ULIMIT_CHECKS to false in your profile or solr.in.sh
Nov 18 13:12:07 ubuntu-01 solr[2903]: [194B blob data]
Nov 18 13:12:07 ubuntu-01 solr[2903]: Started Solr server on port 8983 (pid=2975). Happy searching!
Nov 18 13:12:07 ubuntu-01 solr[2903]: [14B blob data]
Nov 18 13:12:07 ubuntu-01 systemd[1]: Started LSB: Controls Apache Solr as a Service.

Ensure the service is set to start on boot.

$ sudo systemctl enable solr
solr.service is not a native service, redirecting to systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable solr

Step 3: Access Solr Dashboard

By default Solr runs on port 8983 . If you have a UFW firewall running, allow port 8983.

sudo ufw allow 8983

The dashboard should be accessible on the URL.

http://<IP|Hostname>:8983

You should get a dashboard similar to one below:

Step 4: Create Solr Collection

You can now create your first Solr collection:

sudo su - solr -c "/opt/solr/bin/solr create -c collection1 -n data_driven_schema_configs"

Sample output:

INFO - 2018-11-18 13:48:05.538; org.apache.solr.util.configuration.SSLCredentialProviderFactory; Processing SSL Credential Provider chain: env;sysprop
Created new core 'collection1'

Create collection should be visible from the web interface.

Beginning with Solr 4.4, a detailed reference guide is available online or as a PDF download.