Install Apache Solr on CentOS 7

Install Apache Solr on CentOS 7

We’ll show you, how to install Apache Solr on CentOS 7. Apache Solr is an open source enterprise search platform used to easily create search engines which searches websites, files and databases. Its major features include powerful full-text search, faceted search, distributed search, hit highlighting and index replication.
In this tutorial we will show you how to install Apache Solr on a CentOS 7 VPS.

Make sure your operating system is fully up to date by executing the following command:

yum update

Install the latest available version of Java on your server:

yum list available | grep -i jdk


Verify that Java is properly installed:

java -version
java version "1.7.0_65"
OpenJDK Runtime Environment (rhel- u65-b17)
OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)

The next step is to download and unpack the Solr archive. At the time of writing this tutorial, the latest stable version is Solr 4.9. Once you have the package, unpack it into the directory of your choice (in this tutorial we use ‘/opt’ for the Solr 4.9 installation). So, download and unpack Apache Solr 4.9 on your Centos 7 VPS:

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer

Now just $43 .99

cd /opt
tar -xvf solr-4.9.0.tgz
mv /opt/solr-4.9.0 /opt/solr
mv /opt/solr/example /opt/solr/core

Create a systemd service for Solr or if you are used to the old init scripts, you can keep using them. Create an init script for the Solr service:

vi /etc/init.d/solr
# chkconfig: 2345 20 20
# short-description: Solr
# description: Startup script for Apache Solr Server

JAVA="/usr/bin/java -DSTOP.PORT=8079 -DSTOP.KEY=stopkey -jar start.jar"

start() {
echo -n "Starting Solr... "
$JAVA > $LOG_FILE 2>&1 &
sleep 2

    if [ $RETVAL = 0 ]
        echo "done."
        echo "failed. See error code for more information."
    return $RETVAL

stop() {
echo -n "Stopping Solr... "
pkill -f start.jar > /dev/null

    if [ $RETVAL = 0 ]
        echo "done."
        echo "failed. See error code for more information."
    return $RETVAL

case "$1" in
echo $"Usage: solr {start|stop|restart}"
exit 3
exit $RETVAL

Set the proper permission for the ‘solr’ script and make Solr automatically start on server boot:

chmod +x /etc/init.d/solr

chkconfig --add solr

You can now start Solr using the following command:

/etc/init.d/solr start

You should also be able to use the ‘service’ command to start,stop and restart Solr:

service solr start
service solr stop
service solr restart

Once Solr is up and running you should be able to access it through your favorite web browser at
http://server_IP:8983/solr/ (just replace ‘server_IP’ with your server IP address appropriately):

solr admin

Of course you don’t have to Install Apache Solr on CentOS 7,  if you use one of our Apache VPS Hosting services, in which case you can simply ask our expert Linux admins to install Apache Solr search platform for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post, on how to Install Apache Solr on CentOS 7, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.


2 thoughts on “Install Apache Solr on CentOS 7”

  1. Thanks for the tutorial! it worked great on an Amazon EC2 instance running Amazon Linux.

    I had to make a couple of changes to the init.d script to get it to work

    1. Replaced the escaped characters (> with >)
    2. changed java command from
    $JAVA 2> $LOG_FILE &
    $JAVA > $LOG_FILE 2>&1 &
    to get the output to not show on standardout


Leave a Comment

To prove you are human please solve the following *