Solr 4, Jetty 9 and Search API on Ubuntu

Tech Notes

I've just had to do this three times so let's write it down. First let me say I love the new UI for the Solr Admin pages. They've made it out of the nineties!

Much of this is taken from

  1. Lets put all this in /opt
    # cd /opt
  2. Let's make a Solr user
    # adduser solr
  3. Get some files
    # wget
    # wget
    # wget
  4. Copy the start up script into place
    # cp /opt/jetty/bin/ /etc/init.d/solr
    # chmod +x /etc/init.d/solr
  5. Copy the Solr application into Jetty (this is how we do it in Jetty 9)
    # cp -a solr-4.10.2/dist/solr-4.10.0.war /opt/jetty/webapps/solr.war
    # cp -a solr-4.10.2/example/contexts/solr-jetty-context.xml /opt/jetty/
    # cp -a solr-4.10.2/example/lib/ext/* /opt/jetty/lib/ext/
  6. Make a place for Solr
    # mkdir /opt/solr
  7. Copy the Solr config into place
    # cp -a solr-4.10.2/example/solr /opt/solr
    # cp -a solr-4.10.2/dist/ /opt/solr
    # cp -a solr-4.10.2/contrib/ /opt/solr
  8. Make a place for logs
    # mkdir /opt/solr/logs
  9. Everything is owned by Solr
    # chown solr /opt/solr/logs
  10. Start up configuration for Solr
    # vi /etc/default/solr
    JAVA_OPTIONS="-Dsolr.solr.home=/opt/solr/solr $JAVA_OPTIONS"
    JETTY_ARGS="jetty.port=8983 jetty.spdy.port=8443"
  11. Solr is now one directory closer to Jetty than the default configuration shipped with Solr
    # vi solr/solr/collection1/conf/solrconfig.xml
    <!-- modify the path as following as we are a directory closer now -->
    <lib dir="../../contrib/extraction/lib" regex=".*\.jar" />
    <lib dir="../../dist/" regex="solr-cell-\d.*\.jar" />
    <lib dir="../../contrib/clustering/lib/" regex=".*\.jar" />
    <lib dir="../../dist/" regex="solr-clustering-\d.*\.jar" />
    <lib dir="../../contrib/langid/lib/" regex=".*\.jar" />
    <lib dir="../../dist/" regex="solr-langid-\d.*\.jar" />
    <lib dir="../../contrib/velocity/lib" regex=".*\.jar" />
    <lib dir="../../dist/" regex="solr-velocity-\d.*\.jar" />
    <!--  <lib dir="/non/existent/dir/yields/warning" /> -->
  12. Start Solr
    # service solr start
  13. View the Solr admin interface
  14. Add a core for a Drupal Search API project
    # mkdir -p /opt/solr/solr/[corename]/data
  15. Copy the search_api_solr config into place
    # cp -a /opt/search_api_solr/solr-conf/4.x/ /opt/solr/solr/[corename]
    # chown -R solr:solr /opt/solr/solr/[corename]
  16. Visit the Solr admin page[corename]