DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Coding
  3. Languages
  4. How-To install Tomcat 7 and Solr on Centos 5.5

How-To install Tomcat 7 and Solr on Centos 5.5

Mitch Pronschinske user avatar by
Mitch Pronschinske
·
Oct. 24, 11 · Interview
Like (0)
Save
Tweet
Share
19.63K Views

Join the DZone community and get the full member experience.

Join For Free
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.  This tutorial was originally posted on TechSpry.com and the author is Gerasimos Athanasopoulos.

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/
wget http://apache.cc.uoc.gr/tomcat/tomcat-7/v7.0.22/bin/apache-tomcat-7.0.22.tar.gz
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
wget http://apache.cc.uoc.gr//tomcat/tomcat-connectors/native/1.1.22/source/tomcat-native-1.1.22-src.tar.gz
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
make install

Next open up the catalina.sh (where it is probably located at /usr/share/apache-tomcat-7.0.22/bin/catalina.sh) 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) http://apache.forthnet.gr//lucene/solr/3.1.0/apache-solr-3.1.0.tgz.

cd ~/installers
wget http://apache.forthnet.gr//lucene/solr/3.1.0/apache-solr-3.1.0.tgz
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 ${solr.data.dir:/opt/solr/data}.
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"/>
</Context>

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

#!/bin/bash
# description: Tomcat Start Stop Restart
# processname: tomcat
# chkconfig: 234 20 80
JAVA_HOME=/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
CATALINA_HOME=/usr/share/apache-tomcat-7.0.22

case $1 in
start)
sh $CATALINA_HOME/bin/startup.sh
;;
stop)
sh $CATALINA_HOME/bin/shutdown.sh
;;
restart)
sh $CATALINA_HOME/bin/shutdown.sh
sh $CATALINA_HOME/bin/startup.sh
;;
esac
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

Now if you visit http://127.0.0.1:8983 you should see Tomcat’s index page and in http://127.0.0.1:8983/solr Solr’s index page (given no firewall blocking this port).

About the Author:
Gerasimos Athanasopoulos – a.k.a. Gerry


Gerry was born and raised in Athens, Greece. Having a strong background in Mathematics from an early age he chose to study Physics at the Kapodistrian University of Athens. He became interested in the theory of Special Relativity and in the theory of General Relativity. He is the main editor of the biggest part of the book

Special Relativity: An Introduction with 200 Problems and Solutions. He recently became fan of the Ruby programming language and since then he didn’t stop studying and writing applications in Ruby and Ruby on Rails. He is currently employed as a full time Ruby on Rails developer at mynextcar.gr – one of the best Greek web services. When he doesn’t code he watches movies (mostly zombie/post apocalyptic), goes out to bars and drink fairly amounts of alcohol and plays French billiard.

 

Apache Tomcat

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • What Are the Different Types of API Testing?
  • How To Best Use Java Records as DTOs in Spring Boot 3
  • Java REST API Frameworks
  • Distributed Tracing: A Full Guide

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: