Install Solr On Ubuntu

Solr used to be a bear to install but now it comes with an installer that makes it pretty easy.

First confirm you have java:

java -version

If you don’t have java you will see something like this:

The program 'java' can be found in the following packages:
 * default-jre
 * gcj-5-jre-headless
 * openjdk-8-jre-headless
 * gcj-4.8-jre-headless
 * gcj-4.9-jre-headless
 * openjdk-9-jre-headless
Try: sudo apt install <selected package>

Go ahead and install java if you don’t have it:

sudo apt install openjdk-8-jre-headless

If you have java installed correctly, you should see a version description:

java -version
openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-8u181-b13-0ubuntu0.16.04.1-b13)
OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)

Install solr in /opt.

sudo cd /opt

Get the current version of solr from the downloads page.

sudo wget

Extract the installer script from that archive:

sudo tar xzf solr-7.5.0.tgz solr-7.5.0/bin/ --strip-components=2

Run the installer:

sudo bash ./ solr-7.5.0.tgz

The Solr installer has some options you can change if you want but it is usually ok just to change the defaults. If you want to see the options run the installer script without any input:

sudo bash ./

ERROR: Must specify the path to the Solr installation archive, such as solr-5.0.0.tgz

Usage:  [OPTIONS]

  The first argument to the script must be a path to a Solr distribution archive, such as solr-5.0.0.tgz
    (only .tgz or .zip are supported formats for the archive)

  Supported OPTIONS include:

    -d     Directory for live / writable Solr files, such as logs, pid files, and index data; defaults to /var/solr

    -i     Directory to extract the Solr installation archive; defaults to /opt/
             The specified path must exist prior to using this script.

    -p     Port Solr should bind to; default is 8983

    -s     Service name; defaults to solr

    -u     User to own the Solr files and run the Solr process as; defaults to solr
             This script will create the specified user account if it does not exist.

    -f     Upgrade Solr. Overwrite symlink and init script of previous installation.

    -n     Do not start Solr service after install, and do not abort on missing Java

 NOTE: Must be run as the root user

Once you have installed Solr, you can confirm it is running:

sudo service Solr status

You can start and stop Solr like any other Ubuntu process:

sudo service solr stop
sudo service solr start
sudo service solr restart

Leave a Reply