Before Starting let us assume requirement as per below
Operating System : Ubuntu 12.04.4 LTS (Precise Pangolin) Oracle Java (JDK) : Version 1.6.0 update 7 Apache Tomcat : Version 7 Apache Solr : Version 4.4.0
Let’s assume that you have successfully installed Ubuntu 12.04 and logged in to Konsole with root user.
Configure Oracle Java
NOTE : if you have installed another Java versions (like Openjdk) and you want to install and set Oracle Java as your default Java lib then this guide will be useful.
sudo apt-get install tomcat7 tomcat7-admin
This command will install Tomcat7 and other dependency bundle automatically, so you don’t have to worry about other support packages.
Hurray!!! Tomcat7 successfully installed in below directories you can view
Installed on : /usr/share/tomcat7 etc path : /etc/tomcat7
Now since we had installed Tomcat7 successfully its time to configure Tomcat7 user role, edit “tomcat-users.xml” file as per below
sudo kate /etc/tomcat7/tomcat-users.xml
And Add / Edit Lines as per below
<tomcat-users> <role rolename="manager-gui"/> <user username="tomcat" password="secret" roles="manager-gui"/> </tomcat-users>
Now again in command line fire below command
sudo service tomcat7 restart
This will restart Tomcat7, go to your browser and open url
and you are done with Tomcat7 successfully
Install Apache Solr
- Download Apache Solr version 4.4.0
- Unzip the package and move the solr unser /usr/share/solr as per below command
- We are assuming that you have download solr on /home/digitize/Downloads/solr/solr4.4.0
sudo rsync -avrt /home/digitize/Downloads/solr/solr4.4.0/ /usr/share/solr
NOTE : We haven’t used copy (cp) command over here as sometimes they are not able to copy whole directory structure if previously not created!
Now solr is successfully copied to “/usr/share/solr” directory. Next we setup the tomcat application, first issue the following command to copy solr.war into the application root
sudo cp /usr/share/solr/example/webapps/solr.war /usr/share/solr/example/solr/solr.war
Most ImportantOne of the things about running Solr in a container other than the embedded Jetty is that we need to setup the logging. This step is crucial, without doing this solr will never start and you will pull all of your hair out trying to figure out why. Based on the instructions from the Apache Solr Wiki, copy all the jar files from /usr/share/solr/example/lib/ext to /usr/share/tomcat7/lib. and also copy /usr/share/solr/example/resources/log4j.properties to /usr/share/tomcat7/lib. Now after restarting logs of solr will be visibal unser /var/logs/tomcat7 directory
sudo rsync /usr/share/solr/example/lib/ext/ /usr/share/tomcat7/lib
sudo rsync /usr/share/solr/example/resources/log4j.properties /usr/share/tomcat7/lib
Next we add solr to the Catalina config
sudo kate solr.xml
The config file “solr.xml” should look like this:
<Context docBase="/usr/share/solr/example/solr/solr.war" debug="0" crossContext="true"> <Environment name="solr/home" type="java.lang.String" value="/usr/share/solr/example/solr" override="true" /> </Context>
Now restart Tomcat7 and see Solar is successfully installed and running.
sudo service tomcat7 restart
Open browser and navigate to “http://localhost:8189/” and you can find solr in tomcat manager option..!