How-To install Tomcat 7 and Solr on Centos 5.5

In this how-to we are presenting the steps you have to follow in order to install Tomcat 7 and Solr on a Centos 5.5 machine.

Install Java JDK

yum install java-(version)-openjdk
yum install java-(version)-openjdk-devel

where (version) must be a valid version of the JDK.

Install Tomcat 7

cd /usr/shared/
tar -zxvf apache-tomcat-7.0.22.tar.gz
rm apache-tomcat-7.0.22.tar.gz

You can find the version to download from the binary distribution HERE.

Next you must install tomcat native by downloading the source from here:

cd ~
mkdir installers && cd installers
tar -zxvf tomcat-native-1.1.22-src.tar.gz
rm tomcat-native-1.1.22-src.tar.gz
cd tomcat-native-1.1.22-src/jni/native
./configure --with-apr=/usr/bin/apr-1-config --with-java-home=****

**** must be the directory where the java jdk is e.g. /usr/lib/jvm/java-1.6.0-openjdk.x86_64.

make install

Next open up the (where it is probably located at /usr/share/apache-tomcat-7.0.22/bin/ and put export LD_LIBRARY_PATH="/usr/local/apr/lib" at the start of the file.
Finally change Tomcat default listening port by editing the /usr/share/apache-tomcat-7.0.22/conf/server.xml
and changing <Connector port="8989" to 8983 which is Solr's default port.

Install Solr

First download Solr by visiting HERE and choosing the closest mirror and finding solr. An example path is (note that Solr is in 3.1.0 version right now, please adjust version to fit your needs)

cd ~/installers
tar xzvf apache-solr-3.1.0.tgz
mv apache-solr-3.1.0/example/solr /opt/solr
mv apache-solr-3.1.0/dist/apache-solr-3.1.0.war /opt/solr/
cp apache-solr-3.1.0/client/ruby/solr-ruby/solr/conf/schema.xml /opt/solr/conf/

Next edit the /opt/solr/conf/solrconfig.xml and change the dataDir to ${}.
Next we are creating the solr.xml for Tomcat

cd /usr/share/apache-tomcat-7.0.22/conf/
mkdir Catalina
mkdir Catalina/solr
mkdir Catalina/solr/localhost
vim sorl.xml

and add the following to this file:

<?xml version="1.0" encoding="utf-8"?>
<Context docBase="/opt/solr/apache-solr-3.1.0.war" debug="0" crossContext="true">
  <Environment name="solr/home" type="java.lang.String" value="/opt/solr" override="true"/>

Finally we want to make tomcat a service and make it boot on startup. For this we create an init.d script say /etc/init.d/tomcat and put the following script inside

# description: Tomcat Start Stop Restart
# processname: tomcat
# chkconfig: 234 20 80
export JAVA_HOME
export PATH

case $1 in
exit 0

*Note* Edit the file if necessary and change JAVA_HOME and CATALINA_HOME. Now we make the service by /sbin/chkconfig tomcat on to start on boot and start the service by

/etc/init.d/tomcat start

or by

service tomcat start

One more TIP! If your queries contain unicode characters. Make sure you ‘ve set to the connector at conf/server.xml this:

<Connector port="8090" URIEncoding="UTF-8"/>

Now if you visit you should see Tomcat’s index page and in Solr’s index page (given no firewall blocking this port).

5 Comments How-To install Tomcat 7 and Solr on Centos 5.5

  1. Pingback: install solr tomcat in centos sunspot how to | TechSpry | Linux Blog

  2. Pingback: Elektrische Zahnbuerste

  3. Yamuna

    I have followed these instructions to install solr and tomcat in a centos 6.3 , but I have used jdk not openjdk

    while pointing to displayed error message like this

    HTTP Status 404 – /solr

    type Status report

    message /solr

    description The requested resource is not available.
    Apache Tomcat/7.0.35

    can you help to solve this..


Leave a Reply to Yamuna Cancel reply

Your email address will not be published. Required fields are marked *