Installing Solr 5.x on CentOS 7

To install Solr 5.+ on centos 7, you need a JDK, preferably 64 bit:

yum search openjdk

yum -y install java-1.8.0-openjdk.x86_64

Then, download from a mirror and extract Solr:

wget http://mirrors.gigenet.com/apache/lucene/solr/5.2.1/solr-5.2.1.tgz

tar xvf solr-5.2.1.tgz

If everything worked, it should be simple to start:

cd solr-5.2.1

bin/solr start -h 45.55.156.155 -p 8000

To test that Solr is working, you can use wget. This won’t work until it starts up, which takes a 10-30 seconds:

wget localhost:8000

Output:

--2015-08-02 18:57:19--  http://localhost:8000/
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:8000... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://localhost:8000/solr/ [following]
--2015-08-02 18:57:19--  http://localhost:8000/solr/
Reusing existing connection to [localhost]:8000.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘index.html’

[ <=>                    ] 6,079     -.-K/s   in 0s

2015-08-02 18:57:19 (125 MB/s) - ‘index.html’ saved [6079]

If this fails after waiting, run solr again with “-f” to see the error.

bin/solr start -p 8000 -h 45.55.156.155 -p 8000

If you run out of memory, add the “-m” argument (e.g. -m 256m) – by default Solr uses 512mb.

bin/solr start -h 45.55.156.155 -p 8000 -f -m 256m

To access Solr’s administration pages, run SSH and enable port forwarding. With Putty this means adding “-L 8000:localhost:8000” (for our example) to the command line arguments. Once you connect this way, you can use “http://localhost:8000/solr/#/” to connect to the Solr admin panel.