Installing Solr + Tomcat6 on CentOS

Solr doesn’t need tomcat to work. You can use its built-in functionality to run it on port 8983.

But if you need Solr to run as an application in tomcat - keep reading.

First you need to install tomcat and java:

yum install tomcat6 java-1.7.0-openjdk wget

Set Tomcat to start on boot:

chkconfig tomcat6 on

Now let’s download Solr. I recommend placing it in the opt folder:

cd /opt
wget http://apache.spinellicreations.com/lucene/solr/6.2.1/solr-6.2.1.zip
unzip solr-6.2.1.zip
chown -R tomcat solr-6.2.1

Now you need to copy the war file from the Solr folder into tomcat’s applications folder:

cp /opt/solr-6.2.1/dist/solr-6.2.1.war /usr/share/tomcat6/webapps/solr.war

Copy the additional modules into tomcat’s library folder:

cp /opt/solr-6.2.1/example/lib/ext/* /usr/share/tomcat6/lib/

Restart tomcat to create the Solr application’s environment:

service tomcat6 restart

Open the application file for editing:

nano /usr/share/tomcat6/webapps/solr/WEB-INF/web.xml

<env-entry>
       <env-entry-name>solr/home</env-entry-name>
       <env-entry-value>/put/your/solr/home/here</env-entry-value>
       <env-entry-type>java.lang.String</env-entry-type>
    >/env-entry>

This section will be commented out. Remove the comment markers before (<!-) and after (->) it.
Change /put/your/solr/home/here to /opt/solr-6.2.1/example/solr

Just need to tweak tomcat’s settings a bit more:

nano /usr/share/tomcat6/conf/tomcat6.conf

Set the JAVA_HOME environment variable:

JAVA_HOME=`/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.71.x86_64″

Add additional options:

JAVA_OPTS=-Xmx5000m

Make sure the user is set as follows:

TOMCAT_USER=tomcat

Restart tomcat for the changes to take effect:

service tomcat6 restart

After that Solr will be available at the following link:

http://server_ip:8080/solr/
Share Button