Jetty Powered MultiCore Apache Solr and Drupal in Ubuntu 10.04
My previous article explains how to install Tomcat 6 in Ubuntu and deploy the Apache Solr application. If you preffer to deploy it under Jetty, the following steps explain how to install jetty and prepare a multi coresetup of Solr:
apt-get update && apt-get upgrade apt-get install openjdk-6-jdk jetty
This installs the recommended java development kit in Ubuntu and also the jetty libraries. In order to allow jetty to automatically start you have to set NO_START=0 in /etc/default/jetty file.
The next step is to install the Apache Solr Search Integration module:
drush dl apachesolr svn checkout -r22 http://solr-php-client.googlecode.com/svn/trunk/ /srv/example.com/sites/all/modules/apachesolr/SolrPhpClient
Here I am using Drush, but you can also simply download the project files from Drupal Modules and unzip it into your modules folder.
Download Apache Solr search server and copy the files to Jetty
cd ~ wget http://www.motorlogy.com/apachemirror/lucene/solr/1.4.1/apache-solr-1.4.1.tgz tar -zxvf apache-solr-1.4.1.tgz cp ~/apache-solr-1.4.1/dist/apache-solr-1.4.1.war /var/lib/jetty/webapps/solr.war cp -R ~/apache-solr-1.4.1/example/solr/ /usr/share/solr/
So you copied the main war file to Jetty's webapps directory, and the configuration files into /usr/share directory.
You also have to modify the /etc/default/jetty file again and append the solr home directive to JAVA_OPTIONS:
JAVA_OPTIONS="-Dsolr.solr.home=/usr/share/solr"
The one thing left to do is modify the schema and config files to be compatible with drupal:
mv /usr/share/solr/conf/schema.xml /usr/share/solr/conf/schema.xml.original mv /usr/share/solr/conf/solrconfig.xml /usr/share/solr/conf/solrconfig.xml.original ln -s /srv/example.com/sites/all/modules/apachesolr/schema.xml /usr/share/solr/conf/schema.xml ln -s /srv/example.com/sites/all/modules/apachesolr/solrconfig.xml /usr/share/solr/conf/solrconfig.xml
/etc/init.d/jetty stop && /etc/init.d/jetty start
You should have a fully functional solr search server, available at localhost:8080/solr
For a multicore solr environment you have to use the solr.xml file located in the multicore folder of the downloaded solr archive:
cp ~/apache-solr-1.4.1/example/multicore/solr.xml /usr/share/solr/solr.xml
And modify it:
<solr persistent="false">
<cores adminpath="/admin/cores">
<core instancedir="example.com" name="example.com"></core>
</cores>
</solr>This is the configuration file in which you can add as many cores as you want.
Now create the folders, and copy the conf folder to each of them. Because I use this search server only for drupal sites, I prefer to have only one configuration folder which I symlink to the desired cores:
mkdir /usr/share/solr/example.com mkdir /usr/share/solr/example.com/data chown jetty:jetty /usr/share/solr/example.com/data ln -s /usr/share/solr/conf /usr/share/solr/example.com
In this example I created the folder vladgh.com with the folder data inside it, all owned by jetty user. This is only one core. For the second one add another "core name..." in the solr.xml file, and create another directory, etc.
/etc/init.d/jetty stop && /etc/init.d/jetty start
Enable the module and go to the configuration page (http://example.com/admin/settings/apachesolr/settings)
Solr Hostname: localhost
Solr Port: 8080
Solr Path: /solr/example.com (the argument provided here is the name of the core used earlier, case sensitive)
Also you can set the default behaviour in case of failure (to show core drupal results), and make this module the default search engine (Advanced Configuration -- Make Apache Solr Search the default)



