RHEL6, How to install Solr 5.4

Solr is a Java based full-text search service which uses the Apache Lucene search engine. Red Hat Network does not have an offical package for it and it is not available through EPEL for RHEL6. Here is one way to install it with a minimum of effort.

First download a recent version of Java 1.8 and use the [Alternatives] command to make sure it is selected as the default for the operating system. Note this example installs it into /opt
sudo su -


cd /opt
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u40-b25/jdk-8u40-linux-x64.tar.gz"
tar -xzf jdk-8u40-linux-x64.tar.gz

cd /opt/jdk1.8.0_40/
alternatives --install /usr/bin/java java /opt/jdk1.8.0_40/bin/java 3

alternatives --config java
select option #3

java -version

java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b25)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)
Then download a recent version of Solr and  install it. Note that this version of Solr comes with a special script which will install a runtime script in the /etc/init.d directory. [Also] Note in this example Solr is being unpacked into /tmp and the installation script is run relative to /tmp.

cd /tmp
wget --no-cookies --no-check-certificate  http://www.us.apache.org/dist/lucene/solr/5.4.0/solr-5.4.0.tgz
tar -zxvf solr-5.4.0.tgz

cd /tmp/solr-5.4.0
bin/install_solr_service.sh /tmp/solr-5.4.0.tgz

"wait for the completed status message -- it can take a while"

chkconfig solr on

Depending on how you manage your local firewall rules, put an exception in to allow connecting to port 8983. Solr installs a copy of the java based minimal jetty webserver to provide service, it listens on port 8983.

sudo firewall-cmd --zone = public --add-port = 8983 / tcp --permanent
sudo firewall-cmd --reload


iptables -I INPUT -p tcp -m tcp --dport 8983 -j ACCEPT
service iptables save

Be wary of the status of selinux if you don't maintain its "invisible" state for permissions on directories and resources. In this example its shut off.

vi /etc/sysconfig/selinux => disabled

setenforce 0

The installation script will copy files from the unpack location "/tmp" to the "/opt/solr" directory and create a collections directory /var/solr. Make sure its owned by the new solr user, the previously run installation script created a user and group named "solr".

chown -R solr:solr /var/solr

[Be sure] to change user context to the [solr] user, then "Create" a collection and index a collection by "Posting" it.
sudo su - solr
cd /opt/solr
bin/solr create -c documents
bin/post -c documents docs/
cd /opt/solr
bin/solr create -c gettingstarted
bin/post -c gettingstarted example/exampledocs/*.xml
You can now go to the Solr admin panel at http://localhost:8983/solr/