I have gone through this whole sequence a few times now and have yet to find a place that documents in an “easy to follow” format the steps to get started on Solr. So for what it’s worth, I hope the following is helpful to a few people.
Also, please take the time to read some of the stuff on the Solr wiki which contains all the official information from the project.
Getting Tomcat installed and running
Ok, so I am starting on a Mac Air that happens to be running OS X 10.5.8. The first step is to download Tomcat and get it setup. So, let’s go to the Tomcat 6.x download page and get the Core install (I am grabbing the tar.gz file).
Once you have the file, un-compress it (this should create a folder with all of the Tomcat stuff in it). Rename the folder
tomcat and move it to the
/Library directory. Once that is done you should go into the
/Library/tomcat/conf/ directory and edit the
tomcat-users.xml file to add the following line:
<user username="admin" password="admin" roles="manager"/> This creates a user/password admin/admin for us to be able to get into the management interface of Tomcat.
Now to startup Tomcat we need a terminal window (if you haven’t used one already). We need to go to the
/Library/tomcat/bin directory and run the startup script
someprompt$ ./startup.sh If everything goes well it should give you something like this in response
Using CATALINA_BASE: /Library/tomcat
Using CATALINA_HOME: /Library/tomcat
Using CATALINA_TMPDIR: /Library/tomcat/temp
Using JRE_HOME: /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
Using CLASSPATH: /Library/tomcat/bin/bootstrap.jar
You can now go to http://localhost:8080/ and should see the base Tomcat landing page saying If you’re seeing this page via a web browser, it means you’ve setup Tomcat successfully. Congratulations!. Now, follow the link to the Tomcat Manager which should prompt you for username/password (in our case use the admin/admin user we created above). You should now be looking at the Tomcat Web Application Manager.
Our final step here will be to prep Tomcat for our Solr install. Specifically we will tell Tomcat where the Solr configuration will be. To do this you will need to go to
/Library/tomcat/conf/Catalina/localhost (notice the capital C in Catalina) and create a solr.xml file containing the following:
<?xml version="1.0" encoding="utf-8"?>
<Context docBase="/Library/tomcat/webapps/solr.war" debug="0" crossContext="true">
<Environment name="solr/home" type="java.lang.String" value="/etc/solr" override="true"/>
Now, this tells Tomcat that your Solr Home is in /etc/solr (assuming that is where you want to have it). The Solr Home is where we will have the configuration for Solr. Make sure the directory /etc/solr exists (or whichever directory you have as your Solr Home).
Getting Solr installed and running
So, go to the Solr site and follow the links to the downloads. In my case I am now downloading
apache-solr-1.4.0.tgz Once done and after un-compressing the file, you should have a directory containing all of the Solr stuff (in my case the directory name is apache-solr-1.4.0). Remember this directory as we will need to come back to it later.
For now, we need to go back to the Tomcat Web Application Manager page and find the WAR file deploy section towards the bottom of the page. Browse and go to the
apache-solr-1.4.0/dist directory and find the WAR file (mine is called apache-solr-1.4.0.war). Rename the file to whatever you had in the solr.xml file above (I renamed mine solr.war). After selecting the file, press the deploy button which will prompt Tomcat to deploy the Solr package. If everything goes well you should now have a new Tomcat application listed (mine is listed as /solr. If there were any issues at this stage the package would either not be deployed or it could be deployed but not running. With the latter, you should go through the Tomcat logs
/Library/tomcat/logs to get the detail of why things are not working.
Now, while the Solr application deployed fine and is now running, it is not functional yet because we need to provide it with a configuration. If you try to go to the Solr app (clicking the link in the Tomcat manager interface) you should get some sort of Java “barf” along the lines of
HTTP Status 500 - Severe errors in solr configuration. Check your log files for more detailed information on what may be wrong. If you want solr to continue after configuration errors, change:
Now, go and locate the following directory
apache-solr-1.4.0/example/solr This directory contains a sample configuration directory
conf. Copy the whole
conf directory into your Solr Home (for us it is
/etc/solr) Having done so, now go to the Solr app and it should now work and you should see the very simple and bare Welcome to Solr! page!
At this point you have a fully functional Solr server, ready to receive information for indexing and reply to Solr search queries. You should note that in your Solr Home directory there are a couple of directories of interest. conf contains the configuration information and has a number of files. The more important ones being solrconfig.xml and schema.xml which we will modify in part II. Another directory of interest is data which contains the index created by Solr as you “feed” it with your data.
This is it for Part I. In Part II we will modify solrconfig.xml and schema.xml, and we will load and retrieve data from Solr.