Integrating sunspot solr in rails with tomcat7

At a first glance it seems too easy to integrate a gem in rails but when it comes to Tomcat7 and java dependencies it always end up in  tricky part so here it is follow these simple steps to integrate solr with all it's dependencies.

first you need to have java environment
sudo apt-get -y install openjdk-7-jdk
sudo mkdir /usr/java
sudo ln -s /usr/lib/jvm/java-7-openjdk-amd64 /usr/java/default
Install tomcat
sudo apt-get install tomcat7
sudo apt-get install tomcat7-admin
Then download solr (check for a newer version if you want)
sudo wget http://archive.apache.org/dist/lucene/solr/4.8.1/solr-4.8.1.tgz
sudo tar -xvf solr-4.8.1.tgz 
sudo cp -R solr-4.8.1/example/ /opt/solr
Set Solr with Tomcat:
sudo cp -R /opt/solr/lib/ext/* /usr/share/tomcat7/lib/
sudo cp /opt/solr/webapps/solr.war /var/lib/tomcat7/webapps/solr.war
sudo cp -R /opt/solr /var/lib/tomcat7
sudo chown -R tomcat7:tomcat7 /var/lib/tomcat7/solr
service tomcat7 restart
 if you find this error
* no JDK found - please set JAVA_HOME
sudo gedit /etc/default/tomcat7
When the file opens, uncomment the line that sets the JAVA_HOME variable


Tomcat will not actually use your JAVA_HOME environmente variable, but look in some predefined locations and in the JAVA_HOME variable set inside the startup script, as other answers point out. If you don't like messing with the tomcat startup script, you could create a symlink for your preferred java installation, which will be picked up by tomcat.
ln -s /usr/lib/jvm/java-8-oracle /usr/lib/jvm/default-java
 then follow your gem procedures:

Comments

Popular posts from this blog

Installing Wowza Streaming Engine on ubuntu

Highcharts with grouped categories

Completely Uninstall and Install Rubymine on ubuntu