5

I have had mixed success installing Solr via aptitude as the latest stable version in the apt repo seems to be 1.7. What is the best way of installing Solr via aptitude or other means which does not require java experience? I can't seem to find any method of installing Jetty on RHEL or CentOs via yum, either.

Edit

Updated to allow for multi-distribution feedback. Appreciate any advice you can lend.

2 Answers 2

5

On Debian/Ubuntu

The most straightforward installation is pretty easy using tomcat and your package manager. The dependencies will be met automatically.

apt-get install tomcat6

On CentOS/RedHat

You need to grab some alternative repo's to make this possible

Eg.

rpm -Uvh http://download.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
rpm -Uhv http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm

Then you can install the package from yum

yum install yum-priorities ant tomcat6 tomcat6-admin

cd /usr/src/
mkdir sun-java
cd sun-java

Now it gets a little trickier. Sun used to permit direct downloads; but they now have a stupid session validation in place - so download the binary via your PC and upload it to the machine.

You need both the Linux JDK and JRE.

The commands would have been:

wget -O jdk.rpm.bin http://download.oracle.com/otn-pub/java/jdk/6u29-b11/jdk-6u29-linux-x64-rpm.bin
wget -O jre.rpm.bin http://download.oracle.com/otn-pub/java/jdk/6u29-b11/jre-6u29-linux-x64-rpm.bin

You can alternatively use OpenJDK

wget http://jpackage.org/jpackage50.repo -O /etc/yum.repos.d/jpackage50.repo
yum install -y java-1.6.0-openjdk

Once you've uploaded the binaries

chmod +x *.bin
./jre.rpm.bin
./jdk.rpm.bin
ln -s /var/lib/tomcat6 /usr/share/tomcat6

Then the remaining steps

Then drop in your respective selection of solr

mkdir /usr/src/solr
cd /usr/src/solr
wget http://mirrors.ukfast.co.uk/sites/ftp.apache.org/lucene/solr/3.6.1/apache-solr-3.6.1.tgz
tar xvfz apache-solr-3.6.1.tgz
cd apache-solr-3.6.1
cp dist/apache-solr-*.war /var/lib/tomcat6/webapps/solr.war
mkdir -p /var/lib/tomcat6/solr

Then add the Magento solr configuration

INSTALL_DIR="/var/lib/tomcat6/solr"
touch $INSTALL_DIR/solr.xml
CORES=( "staging" "development" "live" )
for CORE in "${CORES[@]}"; do
  mkdir -p $INSTALL_DIR/$CORE/conf $INSTALL_DIR/$CORE/data 
  cp -par /usr/src/solr/apache-solr-3.6.1/example/solr/conf/* $INSTALL_DIR/$CORE/conf
  cp -par /home/path/public_html/lib/Apache/Solr/Conf/* $INSTALL_DIR/$CORE/conf
done

Then set up the cores

cat > /var/lib/tomcat6/solr/solr.xml << EOF
<?xml version="1.0" encoding="UTF-8" ?>
<solr persistent="true" sharedLib="lib">
  <cores adminPath="/admin/cores">
    <core name="staging" instanceDir="staging" config="solrconfig.xml" schema="schema.xml" />
    <core name="development" instanceDir="development" config="solrconfig.xml" schema="schema.xml" />
    <core name="live" instanceDir="live" config="solrconfig.xml" schema="schema.xml" />
  </cores>
</solr>
EOF

Then finally, clean up permissions and restart solr

chown -R tomcat6:tomcat6 /var/lib/tomcat6/solr
/etc/init.d/tomcat6 restart

Then in Magento, you've now got 3 possible independent cores you can use for your store environments.

  • staging/solr
  • development/solr
  • live/solr

Attribution: http://www.sonassi.com/knowledge-base/multiple-solr-cores-for-magento-on-debianubuntucentosredhat/

6
  • I've updated my answer to suit RH/CentOS also. Feb 4, 2013 at 23:28
  • This is solid gold.
    – philwinkle
    Feb 5, 2013 at 4:21
  • ... and also why I prefer the github method. RHEL makes my life very difficult.
    – philwinkle
    Feb 5, 2013 at 4:22
  • care to explain how you make use of the multiple solr 'cores' in Tomcat - how do you point Magento to a specific core? What about with Jetty?
    – philwinkle
    Feb 7, 2013 at 4:44
  • Making use of them is just a case of entering the respective core name as the path in the Magento admin. Instead of /solr you use the path defined above, eg /live/solr. Tomcat is just a wrapper for a Java application, so the process should be similar with Jetty. Feb 7, 2013 at 8:25
0

I've found that the best method of installing Solr, on both Debian distros and especially RedHat/Centos, is via the github repo lbdremy/solr-install - available here.

One caveat - this particular setup requires Jetty. If you'd like to use Solr with Tomcat, you'll have to look at some other resource, here or here. The github repo does some of the hard work for you - setting up the jetty user, pulling down the most recent jdk for Solr, and unpacking everything to relevant directories. It even starts Jetty for you.

I highly recommend installation via this method. It solves all java dependencies right off the bat; plus it ensures that your dev, staging, and production environments are all running the same version. After install, you want to copy your Magento Enterprise Solr Config files from lib/Apache/Solr/conf to your jetty install directory. I did this with a simple:

> cp -R lib/Apache/Solr/conf/* /usr/local/jetty/solr/conf/

Make sure to restart Jetty after copying your configuration files:

> sudo /etc/init.d/jetty restart

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.