Drupal 7 & Apache Solr in 5 minutes
In this post I will explain how you can configure Apache Tomcat, Apache Solr and Drupal 7 in about 5 minutes, taking into account that you have Drupal 7 installed in a Linux based server.
The first step is to install the Tomcat server if you have not already installed it:
aptitude install tomcat6 tomcat6-admin tomcat6-common tomcat6-user
Let's start the server and verify that works:
/etc/init.d/tomcat6 start
Next step is to download the Apache Solr Search Integration module for Drupal 7:
drush dl apachesolr
Now we can install Solr following the Apache Solr module README.txt. As it suggests we shouldn't use the default Ubuntu/Debian package of Apache Solr (solr-tomcat). We must download the latest supported version of Solr from the official site. The latest Solr version supported by the apachesolr drupal module is 3.6.1 so we must download this version not the version 4.0:
wget http://www.eu.apache.org/dist/lucene/solr/3.6.1/apache-solr-3.6.1.tgz
Uncompress the tarball in a safe place, for example /opt or /usr/share
tar xvzf apache-solr-3.6.1.tgz
The Solr package comes with an example application that fits well for development and testing purposes. We first should make a backup of the configuration files on the examples folder:
mv /opt/apache-solr-3.6.1/example/solr/conf/protwords.txt protwords.bak
mv /opt/apache-solr-3.6.1/example/solr/conf/schema.xml schema.bak
mv /opt/apache-solr-3.6.1/example/solr/conf/solrconfig.xml solrconfig.bak
Next step is to copy the configuration files that come with the Apache Solr drupal module or the integration will not work correctly. Copy the configuration files of your Solr version from the apachesolr module folder to the solr examples folder:
cp apachesolr/solr-conf/solr-3.x/* /opt/apache-solr-3.6.1/example/solr/conf/
Now we can test our Solr server starting the application from the examples folder:
cd /opt/apache-solr-3.6.1/example
java -jar start.jar
And now we should see our server running correctly from the following url:
http://yoursite.com:8983/solr/
It's time to enable the Apache Solr Framework and Apache Solr Search modules:
drush en apachesolr apachesolr_search
Verify that Drupal can connect with the Solr server from the following url:
admin/config/search/apachesolr
Try to run cron in order to verify that Solr is indexing your Drupal content correctly:
drush cron
Now you have a Solr search features on your Drupal 7. The next step is to enable Faceted Search but that will be content for another blog post ;)