Apache Solr may be the best search application currently available for Drupal, but it’s not always easy to setup and can be expensive when using a hosting vendor. To address these issues, we implemented SOLR search on Amazon EC2. This article assumes you have knowledge of Ubuntu and the Linux command line, including how to install software using a package manager.

Steps to install Apache solr on EC2:

  • Setup a EC2 Instance (Ubuntu)
  • Download and install system updates
  • Install Java
  • Install Tomcat
  • Install and configure Apache Solr
  • Configure search in Drupal

Setup an EC2 Instance

Setting up a virtual server on EC2 is fairly straightforward. Ubuntu maintains a good guide to getting started with EC2.

Ubuntu EC2 Starters Guide

When setting up the firewall, make sure to allow access only to port 8080 and 22 from the web server and any other IP addresses that would need access. Some shared hosting servers might not allow outgoing traffic through port 8080. In that case, you can ask the host to open that port for your account, or change Tomcat to run on port 80.

Download and Install Software

Once the server is set up, open a SSH connection. The first step is to run a system update to the latest software. Next, we need to install the following packages:

  • openjdk-6-jre-headless
  • tomcat6
  • solr-common

Once the above packages are correctly installed, you will have a working Solr server application.

Configure Drupal and Apache Solr

  • The Solr application will need to be configured to work with Drupal. You will need to change two configuration files: schema.xml and solrconfig.xml. They are located at /etc/solr/conf/. You will replace these files with those that come with the Drupal apachesolr module. If you haven’t installed and enabled the apachesolr module for your Drupal installation, do that now.
  • Copy the schema.xml and solrconfig.xml files to the /etc/solr/conf/ directory. You may also need to set the datadir element in the solrconfig.xml file. In most cases, this can be set to "/var/lib/solr/data".  This is the default location to store solr data when using the Ubuntu package manager to install the application.
  • Last, we need to configure the apachesolr module within Drupal to connect to the solr server. To do so, go to the apachesolr module settings page and fill in the details for your new EC2 Solr server.
  • The server location will be the public DNS, or elastic IP address of the Solr server. Set the port to 8080, or 80 if you changed the port Tomcat listens to. The Solr path for this installation should be set to /solr.
  • Save the settings, and Drupal should have connected to the solr server. You are now ready to setup search and facets on the Drupal site as best fits your site's needs.

The Results

The steps described above provide just a basic installation of Apache Solr 1.4. There are many options available to configure Solr, such as setting up a multisite search index for multiple applications or sites.

If you can get by with an EC2 Microinstance, you can potentially provide Solr search on your Drupal site for no cost during the first year and perhaps less than $20 per month after that.