

While there are several ways to install Tomcat 6 and Apache Solr, we will use the repository version to gain the benefit of automatic updates.
Tomcat6 as Servlet container
sudo apt-get install tomcat6
sudo apt-get install tomcat6-adminApache Solr Search Server
sudo apt-get install solr-tomcat
Once everything has been correctly installed, you should see the message, “It works!” at http://localhost:8080 and “Welcome to Solr!” at http://localhost:8080/solr/
In the default Tomcat installation, no privileges are created for the Tomcat Manager, so in order to make use of the Tomcat Manager GUI, we still have to create the proper role and a corresponding user.
We’ll edit it with Vim: sudo vim etc/tomcat6/tomcat-users.xml
<tomcat-users>
<role rolename="manager-gui"/>
<user username="tomcat" password="tomcat" roles="manager-gui"/>
</tomcat-users>
Now we need to restart Tomcat:
sudo service tomcat6 restart
Now we can start the manager at http://localhost:8080/manager/html. At this point, you could also deploy Java applets, but for our use case, the manager simply provides an overview of our Solr installations.
In order to use Solr with Drupal, we still need to make some adjustments to our Solr configuration.
We’ll start by creating a new directory in the file-system:
/opt/solr-tomcat/solr_cocomore_drupal_demo/
We’ll use Vim to create a new file (sudo vim solr_cocomore_drupal_demo.xml) with the following content:
<Context path="/solr" docBase="/usr/share/solr" debug="0" privileged="true" allowLinking="true" crossContext="true">
<!-- make symlinks work in Tomcat -->
<Resources className="org.apache.naming.resources.FileDirContext" allowLinking="true" />
<Environment name="solr/home" type="java.lang.String" value="/opt/solr-tomcat/solr_cocomore_drupal_demo/" override="true" />
</Context>And we need another file (sudo vim solr.xml), containing the following code:
<solr persistent="false" sharedLib="lib">
<cores adminPath="/admin/cores">
<core name="cocomore_drupal_demo" instanceDir="cocomore_drupal_demo">
<property name="dataDir" value="cocomore_drupal_demo/data" />
</core>
</cores>
</solr>Next we need to create a sub-directory…
sudo mkdir /opt/solr-tomcat/solr_cocomore_drupal_demo/cocomore_drupal_demo
Now we copy the current standard Solr configuration files
cp -R /etc/solr/conf /opt/solr-tomcat/solr_cocomore_drupal_demo/cocomore_drupal_demo/conf
The following files must be present in the conf directory for Apache Solr to function:
solrconfig.xmlschema.xmlelevate.xmlmapping-ISOLatin1Accent.txtprotwords.txtstopwords.txtsynonyms.txtIMPORTANT NOTE!
The files marked in red will be replaced with those included in the ApacheSolr Drupal module.
Now we need to tell Tomcat where our Solr configuration can be found. We will create a symlink for this purpose:
sudo ln -s /opt/solr-tomcat/solr_cocomore_drupal_demo/solr_cocomore_drupal_demo.xml
/etc/tomcat6/Catalina/localhost/solr_cocomore_drupal_demo.xml Important: Set correct privileges!
chmod -R 775 /opt/solr-tomcat/solr_cocomore_drupal_demo/
chown -R root:tomcat6 /opt/solr-tomcat/solr_cocomore_drupal_demo/
Now, when we visit http://localhost:8080/manager/html, we should see our Solr installation (solr_cocomore_drupal_demo).
Before we can activate the Apache Solr Search module, we must first install the SolrPhpClient in the ApacheSolr module’s path, ideally with:
svn checkout -r22 http://solr-php-client.googlecode.com/svn/trunk/ SolrPhpClient
Note: If you do not have SVN installed, you can download the SolrPhpClient from a variety of sources. See the readme file included with the ApacheSolr module for further information.
Now we should activate the following modules:
admin/settings/apachesolr
Since the default settings should match the module, a connection can already be made to Solr. However, we do not want to use the default Solr index, but our own core, so we have some adjustments to make.
The core consists of Corename and Instance, entered in the Solr path field:
/solr_cocomore_drupal_demo/cocomore_drupal_demo
“Number of items to index per cron run:” A reasonable value is 50. Higher values can result in problems during Cron runs.
In the “Advanced configuration” fieldset: we should now set Apache Solr Search as the default (“Enabled”).
In the “Search index” tab, we can now see how many documents are in the index. Of course we don’t have any yet. We can also see the number of items to be sent for indexing. Content is only indexed during Cron runs. So let’s run Cron!
After Cron has run, we should see that there are no items left to send and that documents have been indexed. Please note: There is a delay time after adding new content before it is indexed. In this example, the delay is set to two minutes.
In the “Search fields” tab, we can specify index “weights” for different fields. Higher weight values for a field give it a greater importance in the search results (not to be confused with “weight” in the context of menus or taxonomies where a higher value makes an item appear lower, i.e. “sink”).
Under “Type biasing and exclusing”, we can also apply weights to different content types or exclude a content type from the search index, altogether.
Comments
Other tutos about Solr
Nice tutorial ! More documentation for those who can read french :
http://techoop.insite.coop/content/la-recherche-drupal-avec-solr
I did not take the time to translate it to english, but if someone want to, I'd be glad.
Next step : Drupal 7 and Solr 3 !
Use Jetty instead
If you just use Tomcat so that you are able to use Solr search you should use Jetty instead of Tomcat. Jetty is more lightweight and compact package where as Tomcat is too heavy for this simple purpose. I've written a blog post for setting up Solr + Jetty and you find it from here http://mearra.com/blogs/ilari-makela/power-drupal-search-jetty-apache-solr-ubuntu-1004.
I got a "HTTP Status 403 -
I got a "HTTP Status 403 - Access to the requested resource has been denied" when logged in the tomcat manager webapp
solr-tomcat installs solr v1.4
I'm sure you're aware of it yourself, but just wanted to point out that this installs solr 1.4 rather than the newer 3.5 (which I believe I've heard certain apachesolr-related modules require?)
Awesome tutorial, by the way! Ridiculously illustrative :)