As already stated in another article, Apache SOLR is a very fast and extremely powerful search engine which can easily be connected to your Drupal website (for example) using the Drupal module.
Its major features include powerful full-text search, hit highlighting, faceted search, near real-time indexing, dynamic clustering, database integration, rich document (e.g., Word, PDF) handling, and geospatial search.

In the previous article I explained how to install a basic Apache SOLR server, in this one we will install a multicore server with the latest SOLR 4.7 version.
The installation procedure below works both on Debian 7 and Ubuntu 12.04.


For now, the latest version of Apache SOLR is currently 4.7, and we will install it on a Tomcat 6 web server.

Install Tomcat 6:

apt-get update
apt-get install tomcat6 tomcat6-admin tomcat6-common tomcat6-user -y

Download and install Apache SOLR 4.7

tar -vxf solr-4.7.0.tgz
cp -R solr-4.7.0/ /opt/solr
cp solr-4.7.0/example/webapps/solr.war /opt/solr/
cp -r solr-4.7.0/example/lib/ext/* /var/lib/tomcat6/shared/
mv /opt/solr/example /opt/solr/yourCOMPANYorCUSTOMERname
rm -r /opt/solr/yourCOMPANYorCUSTOMERname/example-DIH
rm -r /opt/solr/yourCOMPANYorCUSTOMERname/exampledocs/
rm -r /opt/solr/yourCOMPANYorCUSTOMERname/solr-webapp/

Setup new context in tomcat pointing to our Solr files:

vi /etc/tomcat6/Catalina/localhost/solr.xml

Fill in the file with the information below:

<?xml version="1.0" encoding="utf-8"?>
<Context docBase="/opt/solr/solr.war" debug="0" crossContext="true">
<Environment name="solr/home" type="java.lang.String" value="/opt/solr/yourCOMPANYorCUSTOMERname/multicore" override="true"/>

Change persistent setting in /opt/solr/yourCOMPANYorCUSTOMERname/multicore/solr.xml from false to true:

<solr persistent="true">

If you don't do this, all changes (cores creations) made in the SOLR web admin interface will be lost when you restart tomcat.

Adjust rights and restart tomcat:

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

At this point, you have everything running.
If you browse the URL "http://SERVERIPADDRESS:8080/solr/" you should see the page below:


Tomcat 6 and Apache SOLR 4.7 are now installed and Drupal can connect to the Solr core.
If you need to change the Apache SOLR configuration files (solrconfig.xml and schema.xml) for your website, they are located in “/opt/solr/yourCOMPANYorCUSTOMERname/multicore/CoreName/conf/”.

Create a new SOLR core

Now, if you want to create a new SOLR core for a new website for example, you just need to do the following:

  1. On the server, duplicate the core0 folder located in /opt/solr/yourCOMPANYorCUSTOMERname/multicore and give it the name you want:

     cp -r /opt/solr/yourCOMPANYorCUSTOMERname/multicore/core0/ /opt/solr/yourCOMPANYorCUSTOMERname/multicore/NewCore
     chown -R tomcat6:tomcat6 /opt/solr/
     /etc/init.d/tomcat6 restart
  2. On the SOLR web admin page, click the "Core Admin" menu and then "Add Core". Change the name and instanceDir with the name of the folder you created above.


For advanced security, if you need to restrict access to Solr to only some servers, you can edit the Tomcat configuration file: “/etc/tomcat6/context.xml”.
For example, if you want to allow only your Drupal web server ( in my case), add the lines below:

<?xml version='1.0' encoding='utf-8'?>
<Valve className="org.apache.catalina.valves.RemoteAddrValve"