Install and Configure SOLR in Mac OS X

submit to reddit

Recently i have worked on Search engine project using the Open Source Lucene and Solr distributions from the Apache project. Solr search is faster than any other search engine especially for larger sites. This post is to share our experience on SOLR . If you want to install, run and maintain Lucene and Solr yourself and if you are a MAC user, then this post is for you.

Follow the below steps to install Solr.

 

Step 1] Download the latest build (http://www.apache.org/dyn/closer.cgi).

 

Step 2] Stop your Servlet Container.

 

Step 3] Unzip the Solr files and move the files into Tomcat WEBAPPS Directory.

Then Goto apache-solr-3.1.tar.gz/dist/ directroy
and move the apache-solr.war file into the tomcat webapps directoy.

In Terminal,

1
2
<code>cd apache-solr-3.1/dist/
cp apache-solr-3.1/dist/apache-solr-3.1.war Library/Tomcat/webapps/solr.war</code>

Step 4] Also move the solr/conf files to the tomcat directory.
We need to move the /solr/ directory in apache-solr-3.1/example/ into some location(in this case /Library/Tomcat/).

1
<code>cp apache-solr-3.1/example/solr Library/Tomcat/</code>

Step 5] Create solr.xml in /Library/Tomcat/conf/Catalina/localhost
We need to create a solr.xml to specify the path for solr home.

1
2
3
<code><Context docBase="/Library/tomcat6/webapps/solr.war" debug="0" crossContext="true">
<Environment name="solr/home" type="java.lang.String" value="/Library/tomcat6/solr" override="true"/>
</Context></code>

Step 6] Now set path for Data Directory.

In Library/Tomcat/solr/conf directory edit the Schema.xml file.
and change the path for dataDir

1
<code>  <dataDir>/Library/tomcat6/solr/data</dataDir></code>

Note: If you dont have the folder data in Tomcat/solr, create a empty folder.

 

Step 7] Start our Tomcat server and goto http://localhost:8080/solr.

If you see the below page.., your install is successful.

 

How to Start Solr as a Service without using Tomcat:

Download Solr (as mentioned in previous steps).

Open “Terminal”. Goto the “example” folder inside Solr folder.

For Eg:   cd Desktop/Solr/example

To Start the solr Server :  start the start.jar file.

1
Command : java -jar start.jar

Now Solr will run in Port 8983. You can check it at [ localhost:8983/solr ].
solr_admin

If you have any query/comments regarding the Solr installation, please comment here.