Table Of Contents

Installing Solr on Red Hat-type Systems

by Peter Lavin

October 20, 2011

Solr is a search server that runs inside a servlet container. This article describes how to install Solr on Red Hat-type systems using Jetty as the servlet container.

It is assumed that you have some understanding of Solr and have determined what changes need to be made to the Solr configuration files.

Configuration and Start up Files

The configuration files for Solr and Jetty are as follows:

File Description Destination jetty init script /etc/init.d/jetty
jetty jetty configuration file /etc/default/jetty
jetty-logging.xml jetty logging config file /opt/apache-solr-3.4.0/app_name/etc/
schema.xml Solr configuration file /opt/apache-solr-3.4.0/app_name/solr/conf
solrconfig.xml Solr configuration file /opt/apache-solr-3.4.0/app_name/solr/conf

The Solr Jetty website has copies of the Jetty configuration files and start up script. Get the Jetty init script and the logging configuration files from this site. The main Jetty configuration file will be created from scratch.

The two Solr configuration files can be created by editing the files found in the example Solr application. If you haven’t already created these files you’ll need to untar the Solr file as described in Installing Solr. Copy the Solr configuration files to the /var/tmp directory on the machine hosting Solr.

The Jetty Config Files

Check the location of the java executable on the machine that will be hosting the Solr server:

shell> which java

Create a file named jetty with the following entries:

JAVA_OPTIONS=”-Dsolr.solr.home=/opt/apache-solr-3.4.0/app_name/solr $JAVA_OPTIONS”
JETTY_ARGS=”etc/jetty.xml etc/jetty-logging.xml”

Change the Solr home directory (app_name) to a suitable value and adjust JAVA_HOME if the output of which java differs from what’s shown above.

The Jetty logging file doesn’t need changing.

Copy these files to /var/tmp on the server hosting Solr.

The Jetty Start up Script

The only change that you need to make to the Jetty init script is to uncomment the chkconfig lines. These lines are readily identifiable and are reproduced below:

# To get the service to restart correctly on reboot, uncomment below (3 lines):
# ========================
chkconfig: 3 99 99
description: Jetty 7 webserver
processname: jetty
# ========================

Once you’ve altered this file copy it to /var/tmp on the server hosting Solr.

Installing Solr

Go to the command line on the server hosting Solr, navigate to /var/tmp and download the latest Solr build from the Apache website. Expand the archived file:

shell> tar zxf apache-solr-3.4.0.tgz

This creates the apache-solr-3.4.0 directory. Move this directory to /opt:

shell> mv apache-solr-3.4.0 /opt

Navigate to the example directory:

shell> cd /opt/apache-solr-3.4.0/example/

You can ensure Solr works by issuing the following command:

shell> java -jar start.jar

You should see output such as the following:

2011-07-06 09:20:14.979:INFO::Logging to STDERR via org.mortbay.log.StdErrLog
2011-07-06 09:20:15.376:INFO::jetty-6.1-SNAPSHOT
2011-07-06 09:20:15.478:INFO::Extract file:/opt/apache-solr-3.3.0/example/webapps/solr.war to
Jul 6, 2011 9:20:16 AM org.apache.solr.core.SolrResourceLoader locateSolrHome
INFO: JNDI not configured for solr (NoInitialContextEx)
Jul 6, 2011 9:20:16 AM org.apache.solr.core.SolrResourceLoader locateSolrHome
INFO: solr home defaulted to 'solr/' (could not find system property or JNDI)
Jul 6, 2011 9:20:16 AM org.apache.solr.core.SolrResourceLoader <init>
Jul 6, 2011 9:20:19 AM org.apache.solr.servlet.SolrUpdateServlet init
INFO: SolrUpdateServlet.init() done
Jul 6, 2011 9:20:19 AM org.apache.solr.handler.component.SpellCheckComponent$SpellCheckerListener
INFO: Loading spell index for spellchecker: default
2011-07-06 09:20:19.100:INFO::Started SocketConnector@
Jul 6, 2011 9:20:19 AM org.apache.solr.core.SolrCore registerSearcher
INFO: [] Registered new searcher Searcher@154e4e31 main

Shut down the jetty server using Control-c. You should see a shutdown message such as the following:

2011-07-06 09:23:04.123:INFO::Shutdown hook executing
2011-07-06 09:23:04.124:INFO::Graceful shutdown SocketConnector@
2011-07-06 09:23:07.202:INFO::Graceful shutdown
2011-07-06 09:23:08.208:INFO::Stopped SocketConnector@
2011-07-06 09:23:08.275:INFO::Shutdown hook complete

This confirms that Solr works with the default configuration.

Move Configuration Files

Navigate to /var/tmp where the configuration files are and copy the Jetty configuration files to their proper locations:

shell> cp jetty /etc/default
shell> cp jetty-logging.xml /opt/apache-solr-3.4.0/example/etc

Copy and rename the init script,

shell> cp /etc/init.d/jetty

Make sure that the script is executable:

shell> chmod +x /etc/init.d/jetty

Navigate to /opt/apache-solr-3.4.0/ and change the example directory to app_name where app_name is the name you want to assign to the Solr home directory:

shell> mv example app_name

Navigate to the app_name/solr/conf directory: and overwrite the schema.xml file in this dir:

shell> cp /var/tmp/schema.xml ./

Do the same with the solrconfig.xml file:

shell> cp /var/tmp/solrconfig.xml ./

Again, you can confirm that your configuration files are correct by starting up Jetty:

shell> cd /opt/apache-solr-3.4.0/app_name/
shell> java -jar start.jar

Use Control-c to shut down the server.

Starting Solr Automatically

You can use chkconfig to ensure that Jetty starts on reboot. Since the jetty start up file has already been added to the /etc/init.d directory you can configure it to restart on reboot in the following way:

shell> chkconfig --add jetty


If you see the message service jetty does not support chkconfig when attempting to add jetty to chkconfig, comment out the lines that you uncommented in The Jetty Start up Script.

Confirm that the service has been added:

shell> chkconfig --list

Start the Jetty server now:

shell> /etc/init.d/jetty start

Check connectivity using curl:

shell> curl http://localhost:8983/solr/select/?q=*:*

You should get a response even though the index is empty.


You may want to rotate the log files created in /opt/apache-solr-3.4.0/app_name/logs.


The Apache Solr website - the place to start with Solr

The Solr 1.4 Enterprise Search Server book - an excellent overview of Solr

The Solr Wiki website - lots of good material here, including configuration files

About the Author

Peter Lavin is a technical writer who has been published in a number of print and online magazines. He is the author of Object Oriented PHP published by No Starch Press and a contributor to PHP Hacks by O’Reilly Media.