Solr is a open source Enterprise Search Engine. It can be deployed as war file in servlet containers like tomcat or jetty.
This short howto show you run solr with the current Tomcat 7 version:
- Download Solr as Zip
- Unzip it e.g. in /usr/share/ with folder structure
- mv apache-solr-3.5.0.zip /usr/share
- cd /usr/share
- unzip apache-solr-3.5.0.zip
- result is a folder /usr/share/apache-solr-3.5.0
- Create a new folder e.g /usr/share/solr as base folder for the configuration
- cp -a /usr/share/apache-solr-3.5.0/example/solr /usr/share/solr
- cp /usr/share/apache-solr-3.5.0/dist/*.war /usr/share/solr
- ln -s /usr/share/solr/apache-solr-3.5.0.war /usr/share/solr.war
- mkdir /usr/share/solr/data< for index data/li>
- mkdir /usr/share/solr/lib for additional jars
- cp /usr/share/apache-solr-3.5.0/dist/apache-solr-velocity-3.5.0.jar /usr/share/solr/lib
- cp -a /usr/share/apache-solr-3.5.0/contrib/ /usr/share/solr/
- nano /usr/share/solr/conf/solrconfig.xml and change the lib settings
- chown -R tomcat:tomcat /usr/share/solr if tomcat server runs as user tomcat
- Add URIEncoding to tomcat connector settings
- nano /usr/share/tomcat7/conf/server.xml
- search for the connector on port 8080
- add the URIEncoding like this:
- Create a tomcat configuration file for solr (CATALINA_HOME is /usr/share/tomcat7)
- cd /usr/share/tomcat7/conf
- mkdir Catalina (if not exists)
- cd Catalina
- mkdir localhost (if not exists)
- cd localhost
- nano solr.xml
- Paste the following configuration and save the file
// ...
- Set properties for tomcat and solr inside /usr/share/tomcat7/bin/setenv.sh
- Paste the following configuration and save the file
export JAVA_OPTS="$JAVA_OPTS -Dsolr.solr.home=/usr/share/solr" export JAVA_OPTS="$JAVA_OPTS -Dsolr.data.dir=/usr/share/solr/data" export JAVA_OPTS="$JAVA_OPTS -Dsolr.velocity.enabled=true" export JAVA_HOME="/usr/lib/jvm/default-java"
- (Re)start tomcat
- /etc/init.d/tomcat7 restart
- Open browser and go to http://YOUR_SERVER_HOSTNAME:8080/solr/admin/ assuming that tomcat runs under default port 8080
I use the provided sample xml files to see if import and query functionality works:
- cd /usr/share/apache-solr-3.5.0/example/exampledocs
- nano post.sh
- change the URL parameter to your environment e.g. to URL=http://localhost:8080/solr/update
- ./post.sh *.xml
- Open the admin ui under http://YOUR_SERVER_HOSTNAME:8080/solr/admin/
- click the search button
see my follow up post for Configuring solr, tomcat 7 with mod_jk and apache 2.2