Linux Sysadmin Blog

Install Apache Solr Multicore for Drupal

- | Comments

Yesterday I received new installation request from developers to install ApacheSolr module for Drupal. Check this link for more details on Apache Solr Search Integration. Since this is new to me I spent some time on searching and doing test installations. To make it short below is my setup on our shared hosting server running CentOS with Cpanel.

Type: Multi-core (for possible use on other Drupal sites) Java Servlet Container: Jetty (built-in on Solr) Drupal version: 6 Java: 1.6

I based this guide plainly from this DrupalĀ  page, and I made this summary for my own future reference.

Process:

You need to have the Java installed first.

1) ApacheSolr Drupal Module

1.1) Download and install ApacheSolr module to your site/s. Traditional download, extract, and enable method.

1.2) Download SolrPHPClient (PHP library) and extract the the files inside of your ApacheSolr Drupal module. Example:

1
sites/all/modules/apachesolr/SolrPhpClient

2) Solr:

2.1) Select a directory where you want to put your Solr files as long as it is not accessible to the web. Example:

1
/home/solr

2.2) Download nightly build of Solr and extract to your selected directory. Example:

1
/home/solr/apache-solr-nightly

2.3) Copy example directory to another directory like drupal. Example:

1
cp -r /home/solr/apache-solr-nightly/example /home/solr/apache-solr-nightly/drupal

2.4) Copy schema.xml and solrconfig.xml files from your ApacheSolr Drupal module.

1
2
cp /path_to_site/sites/all/modules/apachesolr/schema.xml /home/solr/apache-solr-nightly/drupal/schema.xml
cp /path_to_site/sites/all/modules/apachesolr/solrconfig.xml /home/solr/apache-solr-nightly/drupal/solrconfig.xml

2.5) Copy ”/home/solr/apache-solr-nightly/drupal/multicore/solr.xml” to ”/home/solr/apache-solr-nightly/drupal/solr/solr.xml

2.6) Create directory for each site that will use the ApacheSolr inside ”/home/solr/apache-solr-nightly/drupal/solr” and copy /home/solr/apache-solr-nightly/drupal/conf to each of them. Example:

1
2
3
4
mkdir /home/solr/apache-solr-nightly/drupal/solr/site_drupalsite1
cp -r /home/solr/apache-solr-nightly/drupal/conf /home/solr/apache-solr-nightly/drupal/solr/site_drupalsite1/
mkdir /home/solr/apache-solr-nightly/drupal/solr/site_drupalsite2
cp -r /home/solr/apache-solr-nightly/drupal/conf /home/solr/apache-solr-nightly/drupal/solr/site_drupalsite2/

2.7) Edit /home/solr/apache-solr-nightly/drupal/solr.xml and add the details/path of your site/s. Example:

1
2
3
4
<cores adminPath="/admin/cores">
<core name="drupalsite1" instanceDir="site_drupalsite1" />
<core name="drupalsite2" instanceDir="site_drupalsite2" />
</cores>

2.8) Start the Jetty servlet container.

1
2
cd /home/solr/apache-solr-nightly/drupal/
java -jar start.jar

2.9) Finally, visit Drupal Admin settings for ApacheSolr module to set the correct Solr path.
Example:

1
2
Drupal Site1:  /solr/drupalsite1
Drupal Site2:  /solr/drupalsite2

That’s it - we now have our complete ApacheSolr search integration. Check the ApacheSolr documentation for more details on using this module.

Solr server is started manually and to make it running on start up or if you want to be able to start/stop/restart the server, please refer to this blog post.

To add new sites (new sites with ApacheSolr module) just repeat steps 1 and 2.6 - 2.9, and restart the Solr server.

Comments