Zénobe Grammestraat 34,
2018 Antwerp, Belgium
Call us: +32 (0) 3 298 69 98
Email us: info@krimson.be
Wow, I spent alot of time to make this guide as simple as possible. This is my second try in making a simple Apache Solr Setup Guide.
One good advice, never use the tomcat or the solr packages from ubuntu or any others...! REALLY!!! It will make a little mess in your filesystem and you can't get control anymore of the paths that are in use.
So if you have a clean server try this to make Apache Solr working
Note : Java is required (preferably the java 6 from Sun)
Get the latest tomcat release and put it in your home directory
(http://tomcat.apache.org/download-60.cgi)
Grab the latest Apache Solr and put it in your home directory as well (http://apache.belnet.be/lucene/solr/ or the nightly build. In this example I used the nightly build)
cd ~/ tar zxvf apache-tomcat-6* tar zxvf apache-solr-*
sudo mv apache-tomcat-6.0.18/ /usr/local/tomcat6/
sudo cp apache-solr-nightly/dist/apache-solr-nightly.war /usr/local/tomcat6/webapps/solr.war sudo cp -r apache-solr-nightly/example/solr/ /usr/local/tomcat6/solr/
sudo nano /usr/local/tomcat6/conf/Catalina/localhost/solr.xml
In this file, insert the following code:
<Context docBase="/usr/local/tomcat6/webapps/solr.war" debug="0" crossContext="true" > <Environment name="solr/home" type="java.lang.String" value="/usr/local/tomcat6/solr" override="true" /> </Context>
Edit your .bashrc file in your home directory and add the following to it:
Make sure the JAVA_HOME path is correct. Look for a java-6-sun* folder
export JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.10 export JAVA_OPTS="$JAVA_OPTS -Dsolr.solr.home=/usr/local/tomcat6/solr" export CATALINA_BASE=/usr/local/tomcat6 export CATALINA_HOME=/usr/local/tomcat6
/usr/local/tomcat6/bin/startup.sh
If all went well, you should be able to start Tomcat and browse to http://localhost:8080/solr/admin and see the Solr admin page.
If this worked, great, but now it's time to get Tomcat to autostart itself when your server reboots. First, open a new script in your /etc/init.d/ directory.
sudo nano /etc/init.d/tomcat6
# Tomcat auto-start # # description: Auto-starts tomcat # processname: tomcat # pidfile: /var/run/tomcat.pid export JAVA_HOME=/usr/lib/jvm/java-6-sun-1.6.0.10 export JAVA_OPTS="$JAVA_OPTS -Dsolr.solr.home=/usr/local/tomcat6/solr" case $1 in start) sh /usr/local/tomcat6/bin/startup.sh ;; stop) sh /usr/local/tomcat6/bin/shutdown.sh ;; restart) sh /usr/local/tomcat6/bin/shutdown.sh sh /usr/local/tomcat6/bin/startup.sh ;; esac exit 0
sudo update-rc.d tomcat6 start 91 2 3 4 5 . stop 20 0 1 6 .
/etc/init.d/tomcat6 stop /etc/init.d/tomcat6 start /etc/init.d/tomcat6 restart
robertDouglass wrote and maintains the excellent Apache Solr module. The module is integrated in the Acquia distributiun, or can be downloaded separately from Drupal.org.
We are going to copy our solrconfigs and schema from the drupal module to our directory
If you have an acquia distribution :
sudo cp /var/www/YOURWEBSITE/modules/acquia/apachesolr/solrconfig.xml /usr/local/tomcat6/solr/conf/solrconfig.xml sudo cp /var/www/YOURWEBSITE/modules/acquia/apachesolr/schema.xml /usr/local/tomcat6/solr/conf/schema.xml
If you downloaded the module, install it and don't forget to checkout the important SolrPhpClient library (see the apachesolr README.txt)
cd /var/www/YOURWEBSITE/sites/all/modules/contrib/apachesolr/ sudo cp /var/www/YOURWEBSITE/sites/all/modules/contrib/apachesolr/solrconfig.xml /usr/local/tomcat6/solr/conf/solrconfig.xml sudo cp /var/www/YOURWEBSITE/sites/all/modules/contrib/apachesolr/schema.xml /usr/local/tomcat6/solr/conf/schema.xml
Enable the module in the modules list and go to the config screen
fill in the next parameters :
Solr host name:
Host name of your Solr server, e.g. localhost or example.com (check the beginning, mostly localhost)
localhost
Solr port:
Port on which the Solr server listens. Tomcat is 8080 by default.
8080
Solr path:
Path that identifies the Solr request handler to be used.
solr
Enable spellchecker is a nice feature :-)
And click save configuration.
It's possible you'll have to click save twice for all the notices to disappear. If you do see them, check if all your variables are correct or refresh.
Click on the search index tab in our drupal site and just for caution, click on delete index (don't forget the checkbox) and click on re-index all content and run cron.
We are going to create a second configuration file and another apache solr directory for our site-specific files and insert the following configuration
sudo nano /usr/local/tomcat6/conf/Catalina/localhost/site2.xml
<Context docBase="/usr/local/tomcat6/webapps/solr.war" debug="0" crossContext="true" > <Environment name="solr/home" type="java.lang.String" value="/usr/local/tomcat6/site2" override="true" /> </Context>
cd /usr/local/tomcat6 cp -r ~/apache-solr-nightly/example/solr/ /usr/local/tomcat6/site2 cd /usr/local/tomcat6/webapps cp -r solr site2
/etc/init.d/tomcat6 restart
Great Guide!
Just wanted to say thanks for creating such a thorough guide for this. I've read a lot of guides and this is the first one that worked flawlessly. (And one of the only ones showing a good init.d script - many completely miss getting Solr to start on reboot!)
Thanks!
I understand...
...now i'm going to test it. thanks for writing :)
Truly,
it works!
Post new comment