Reader small image

You're reading from  Apache Solr PHP Integration

Product typeBook
Published inNov 2013
Reading LevelIntermediate
PublisherPackt
ISBN-139781782164920
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Jayant Kumar
Jayant Kumar
author image
Jayant Kumar

Jayant Kumar is an experienced software professional with a bachelor of engineering degree in computer science and more than 14 years of experience in architecting and developing large-scale web applications. Jayant is an expert on search technologies and PHP and has been working with Lucene and Solr for more than 11 years now. He is the key person responsible for introducing Lucene as a search engine on www.naukri.com, the most successful job portal in India. Jayant is also the author of the book Apache Solr PHP Integration, Packt Publishing, which has been very successful. Jayant has played many different important roles throughout his career, including software developer, team leader, project manager, and architect, but his primary focus has been on building scalable solutions on the Web. Currently, he is associated with the digital division of HT Media as the chief architect responsible for the job site www.shine.com. Jayant is an avid blogger and his blog can be visited at http://jayant7k.blogspot.in. His LinkedIn profile is available at http://www.linkedin.com/in/jayantkumar.
Read more about Jayant Kumar

Right arrow

Configuring Tomcat to run Solr


The web server jetty used by default Solr is meant for development purposes only. For production environment, we would want Solr to run as a part of a more convenient setup involving a more reliable web server. Solr can be configured to run on any J2EE container such as IBM Websphere or JBoss or any other server. Apache Tomcat is the most commonly used server. Let us see how to set up Solr as a part of Apache Tomcat web server. We have Apache Tomcat installed on our Windows or Linux environment.

To run Solr as a part of Apache Tomcat web server, you need to create a context for /solr in the configuration. The following solr.xml file needs to be put at the appropriate location in Windows and Linux inside the Tomcat configuration folder at <tomcat_home>/conf/Catalina/localhost.

<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="/home/jayant/solr-4.3.1/example/webapps/solr.war" >
<Environment name="solr/home" type="java.lang.String" value="/home/jayant/solr-4.3.1/example/solr" override="true" />
</Context>

Change docBase to <solr_path>/example/webapps/solr.war and the value attribute in Environment to <solr_path>/example/solr. The environment named solr/home tells Tomcat the location where Solr configuration files are to be found. In addition to this, let us change the configuration of Solr in the <solr_path>/example/solr/solr.xml file. Search for hostPort and change it to match Tomcat's port 8080. Similarly search for hostContext and change it to solr.

Note

Windows users, use \ instead of / in your configuration XML files for path variables. Do not change the / in solr/home.

Restart your Tomcat server and you should be able to go to the following URL to see Solr working along with Tomcat:

http://localhost:8080/solr/

Tip

If you see an error "404 not found" on the preceding URL, it may be because of some libraries of Solr that Tomcat is not able to find. You can check the exact error in Tomcat error logs in the <tomcat_home>/logs/catalina.out folder. To resolve the missing library issue, copy all JAR files from the <solr_home>/example/lib/ext to <tomcat_home>/lib folder.

You can also enable advanced logging in your Tomcat logs by copying the log4j.properties file from the <solr_home>/example/resources folder to your <tomcat_home>/lib folder.

Previous PageNext Page
You have been reading a chapter from
Apache Solr PHP Integration
Published in: Nov 2013Publisher: PacktISBN-13: 9781782164920
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Jayant Kumar

Jayant Kumar is an experienced software professional with a bachelor of engineering degree in computer science and more than 14 years of experience in architecting and developing large-scale web applications. Jayant is an expert on search technologies and PHP and has been working with Lucene and Solr for more than 11 years now. He is the key person responsible for introducing Lucene as a search engine on www.naukri.com, the most successful job portal in India. Jayant is also the author of the book Apache Solr PHP Integration, Packt Publishing, which has been very successful. Jayant has played many different important roles throughout his career, including software developer, team leader, project manager, and architect, but his primary focus has been on building scalable solutions on the Web. Currently, he is associated with the digital division of HT Media as the chief architect responsible for the job site www.shine.com. Jayant is an avid blogger and his blog can be visited at http://jayant7k.blogspot.in. His LinkedIn profile is available at http://www.linkedin.com/in/jayantkumar.
Read more about Jayant Kumar