How To Install Apache Solr on CentOS 7

Install Apache Solr on CentOS 7

In this tutorial, we will show you how to install and configuration of Apache Solr on your CentOS 7 server.  For those of you who didn’t know, Apache Solr is an open-source search platform written on Java. It is based on Apache Lucene and is written in Java. Just like Elasticsearch, it supports database queries through REST APIs. Solr aims at providing distributed indexing, replication, and load-balanced querying with automated failover and recovery.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple. I will show you the step-by-step installation of Apache Solr in CentOS 7.


  • A server running one of the following operating systems: CentOS 7.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Apache Solr on CentOS 7

Step 1. First, let’s start by ensuring your system is up-to-date.

yum -y update

Step 2. Install the latest available version of Java on your server.

yum list available java*
yum install java-1.8.0-openjdk.x86_64

Checking Installed java version:

which java
java -version

Step 3. Installing Apache Solr.

The first thing to do is to go to Apache Solr’s download page and download the latest stable version of Apache Solr, At the moment of writing this article it is version 5.4.0:

wget http://apache.org/dist/lucene/solr/5.4.0/solr-5.4.0.tgz

Unpack the Apache Solr archive to the document root directory on your server:

tar -xvf solr-5.4.0.tgz
mv /opt/solr-5.4.0 /opt/solr
mv /opt/solr/example /opt/solr/core

Step 4. Create a script for handling the Solr server service.

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:

nano /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

Save the file and make it executable:

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

Step 5. Configure Iptables or Firewall.

If you use Iptables add a rule to allow access to Solr’s admin section and query Solr data:

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

Step 6. Accessing Apache Solr.

Apache Solr will be available on HTTP port 8983 by default. Open your favorite browser and navigate to http://your-domain.com:8983/solr/  or http://your-server-ip:8983/solr/.

Install Apache Solr on CentOS 7
Apache Solr

Congratulations! You have successfully installed Apache Solr. Thanks for using this tutorial for installing Apache Solr on your CentOS 7 system. For additional help or useful information, we recommend you check the official Apache Solr website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!


r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button