{"id":2272,"date":"2015-01-05T18:15:44","date_gmt":"2015-01-05T16:15:44","guid":{"rendered":"http:\/\/www.extradrm.com\/?p=2272"},"modified":"2020-09-07T20:02:42","modified_gmt":"2020-09-07T18:02:42","slug":"solr-4-jetty-9-and-search-api-on-ubuntu","status":"publish","type":"post","link":"http:\/\/www.extradrm.com\/?p=2272","title":{"rendered":"Install Solr 4.9 Jetty 9 and Drupal Search API on Ubuntu"},"content":{"rendered":"<p><a href=\"https:\/\/dcvan24.wordpress.com\/2013\/05\/16\/how-to-deploy-solr-4-3-on-jetty-9\/\">How to Deploy Solr 4.3 On Jetty&nbsp;9<\/a><br \/>\nhttps:\/\/www.digitalocean.com\/community\/tutorials\/how-to-install-solr-on-ubuntu-14-04<br \/>\nhttp:\/\/hollysydney.com\/article\/solr-4-jetty-9-and-search-api-ubuntu<br \/>\nhttp:\/\/pietervogelaar.nl\/ubuntu-12-04-install-solr-4-with-jetty-9<br \/>\nhttp:\/\/zetcode.com\/java\/jetty\/install\/<\/p>\n<h2><strong>1- Install openjdk<\/strong><\/h2>\n<p>Jetty 9 requires JDK 7, so if you don\u2019t have it installed, install it first. In Ubuntu, it is very convenient to install openjdk using apt-get. For this section, we will be using Jetty instead of Tomcat. If you want a simple installation, execute the following command :<\/p>\n<div><code>apt-get install -y openjdk<\/code><code>-7<\/code><code>-jdk<\/code><\/div>\n<div><code>mkdir -p \/usr\/java<\/code><\/div>\n<div><code>ln -s \/usr\/lib\/jvm\/java<\/code><code>-7<\/code><code>-openjdk-amd<\/code><code>64<\/code> <code>\/usr\/java\/<\/code><code>default<\/code><strong><\/strong><\/div>\n<div><\/div>\n<div>\n<p><strong><em>Note : How to know that Java is installed in a Linux system?<\/em><\/strong><\/p>\n<p>In your terminal type java -version or just javac if it returns something, then you&#8217;ve java installed. Otherwise, there is also the possibility that the path variables do not contain the java path. So use locate jdk or locate java to see if you have the java binary. Don&#8217;t forget to run updatedb if you are using locate for the first time.<\/p>\n<p>In case an old version is installed we must do the following before getting jetty9 or tomcat 7<\/p>\n<pre>$ sudo apt-get purge oracle-java6-installer\n$ sudo apt-get install software-properties-common python-software-properties\n$ sudo add-apt-repository ppa:webupd8team\/java\n$ sudo apt-get update\n$ sudo apt-get install oracle-java7-installer<\/pre>\n<\/div>\n<div>Then install for example :<\/div>\n<div>\n<pre>$ sudo apt-get install tomcat7 tomcat7-admin<\/pre>\n<\/div>\n<h2><strong>2- Install Jetty 9<\/strong><\/h2>\n<p>Get Jetty 9: <a href=\"http:\/\/eclipse.org\/downloads\/download.php?file=\/jetty\/stable-9\/dist\/jetty-distribution-9.0.3.v20130506.tar.gz&amp;r=1\" rel=\"nofollow\">http:\/\/eclipse.org\/downloads\/<\/a><\/p>\n<p>Extract the tarball of Jetty 9 to a preferred directory, e.g. \/opt. Then set $JETTY_HOME, create a new user called \u201cjetty\u201d and make it the owner of $JETTY_HOME.<\/p>\n<div>\n<div><code>tar -zxvf jetty-distribution<\/code><code>-<\/code><code>9.2.6.v20141205<\/code><code>.tar.gz -C \/opt<\/code><\/div>\n<div><code>mv \/opt\/jetty-distribution<\/code><code>-<\/code><code>9.2.6.v20141205<\/code><code>\/ \/opt\/jetty\/<\/code><\/div>\n<div><code>useradd jetty -U -s \/bin\/false<\/code><\/div>\n<div><code>chown -R jetty:jetty \/opt\/jetty<\/code><\/div>\n<\/div>\n<p>Note : If you want to change the port Jetty runs on, edit start.ini in $JETTY_HOME and change jetty.port<br \/>\nsudo nano \/opt\/jetty\/start.ini<br \/>\n&#8230;<\/p>\n<p>#=============<br \/>\n# HTTP Connector<br \/>\n#&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\njetty.port=9090<br \/>\nhttp.timeout=30000<br \/>\netc\/jetty-http.xml<\/p>\n<p>&#8230;<\/p>\n<h2><strong>3- Install Solr package and test it<br \/>\n<\/strong><\/h2>\n<p>We can now start the real installation of Solr. First, download all files and uncompress them:<\/p>\n<pre>cd \/opt\nwget http:\/\/archive.apache.org\/dist\/lucene\/solr\/4.9.1\/solr-4.9.1.tgz\ntar -zxvf solr-4.9.1.tgz<\/pre>\n<p><strong><em>Make a quick test to see if it works &#8230;<\/em><\/strong><\/p>\n<p>cp -R solr-4.9.1\/example \/opt\/solr<br \/>\ncd \/opt\/solr\/example<br \/>\njava -jar start.jar<\/p>\n<p>Check if it works by visiting <code>http:\/\/YOUR_IP:8983\/solr<\/code>. When it works, go back into your SSH session and close the window with Ctrl+C to stop java. Now we will make it work <span style=\"text-decoration: underline;\">without java-jar start.jar<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Make a place for Solr<\/strong><br \/>\n# mkdir \/opt\/solr<br \/>\nCopy the Solr config into place<br \/>\n# cp -a solr-4.9.1\/example\/solr \/opt\/solr<br \/>\n# cp -a solr-4.9.1\/dist\/ \/opt\/solr<br \/>\n# cp -a solr-4.9.1\/contrib\/ \/opt\/solr<\/p>\n<p>Make a place for logs<br \/>\n# mkdir \/opt\/solr\/logs<\/p>\n<p><span style=\"text-decoration: underline;\"><strong>Everything is owned by Solr:<\/strong><br \/>\n<\/span>Create the Solr user and grant it permissions:<\/p>\n<pre>sudo useradd -d \/opt\/solr -s \/sbin\/false solr\nsudo chown solr:solr -R \/opt\/solr<\/pre>\n<h2>4-Configure Jetty for SolR :<\/h2>\n<p><strong>a- Create the settings file of jetty in \/etc\/default :<\/strong><br \/>\nsudo nano \/etc\/default\/jetty<\/p>\n<p>and paste following in it.<\/p>\n<pre>NO_START=0 # Start on boot\nJAVA_OPTIONS=\"-Dsolr.solr.home=\/opt\/solr\/solr $JAVA_OPTIONS\"\nJAVA_HOME=\/usr\/java\/default\nJETTY_HOME=\/opt\/jetty\nJETTY_USER=solr\nJETTY_LOGS=\/opt\/solr\/logs<\/pre>\n<p>Save it.<\/p>\n<p><strong>b- Copy script jetty.sh to \/etc\/init.d\/ to make it run as a service.<\/strong><br \/>\ncp -a \/opt\/jetty\/bin\/jetty.sh \/etc\/init.d\/jetty (which come with the jetty package install)<\/p>\n<p>or<\/p>\n<pre><code lang=\"\">sudo wget -O \/etc\/init.d\/jetty http:\/\/dev.eclipse.org\/svnroot\/rt\/org.eclipse.jetty\/jetty\/trunk\/jetty-distribution\/src\/main\/resources\/bin\/jetty.sh\nsudo chmod a+x \/etc\/init.d\/jetty\nsudo update-rc.d jetty defaults<\/code><\/pre>\n<p><strong>c- Create log for jetty under SolR<\/strong><\/p>\n<p>open the file \/opt\/solr\/etc\/jetty-logging.xml (nano \/opt\/solr\/etc\/jetty-logging.xml) and paste this into it:<\/p>\n<pre>&lt;?xml version=\"1.0\"?&gt;\n  &lt;!DOCTYPE Configure PUBLIC \"-\/\/Mort Bay Consulting\/\/DTD Configure\/\/EN\" \"http:\/\/jetty.mortbay.org\/configure.dtd\"&gt;\n  &lt;!-- =============================================================== --&gt;\n  &lt;!-- Configure stderr and stdout to a Jetty rollover log file --&gt;\n  &lt;!-- this configuration file should be used in combination with --&gt;\n  &lt;!-- other configuration files.  e.g. --&gt;\n  &lt;!--    java -jar start.jar etc\/jetty-logging.xml etc\/jetty.xml --&gt;\n  &lt;!-- =============================================================== --&gt;\n  &lt;Configure id=\"Server\"&gt;\n\n      &lt;New id=\"ServerLog\"&gt;\n        &lt;Arg&gt;\n          &lt;New&gt;\n            &lt;Arg&gt;&lt;SystemProperty name=\"jetty.logs\" default=\".\"\/&gt;\/yyyy_mm_dd.stderrout.log&lt;\/Arg&gt;\n            &lt;Arg type=\"boolean\"&gt;false&lt;\/Arg&gt;\n            &lt;Arg type=\"int\"&gt;90&lt;\/Arg&gt;\n            &lt;Arg&gt;&lt;Call name=\"getTimeZone\"&gt;&lt;Arg&gt;GMT&lt;\/Arg&gt;&lt;\/Call&gt;&lt;\/Arg&gt;\n            &lt;Get id=\"ServerLogName\" name=\"datedFilename\"\/&gt;\n          &lt;\/New&gt;\n        &lt;\/Arg&gt;\n      &lt;\/New&gt;\n\n      &lt;Call name=\"info\"&gt;&lt;Arg&gt;Redirecting stderr\/stdout to &lt;Ref id=\"ServerLogName\"\/&gt;&lt;\/Arg&gt;&lt;\/Call&gt;\n      &lt;Call name=\"setErr\"&gt;&lt;Arg&gt;&lt;Ref id=\"ServerLog\"\/&gt;&lt;\/Arg&gt;&lt;\/Call&gt;\n      &lt;Call name=\"setOut\"&gt;&lt;Arg&gt;&lt;Ref id=\"ServerLog\"\/&gt;&lt;\/Arg&gt;&lt;\/Call&gt;&lt;\/Configure&gt;<\/pre>\n<p>Then, grant it permissions again under solr user :<\/p>\n<pre>sudo chown solr:solr -R \/opt\/solr<\/pre>\n<p>&nbsp;<\/p>\n<p>Now start Jetty as a service.<br \/>\nservice jetty start<\/p>\n<p>Once it prompts \u201cStarting Jetty: OK\u201d, you can visit http:\/\/localhost:8080\/ to see the welcome page of Jetty 9.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<div><code>cp -a solr<\/code><code>-4.9<\/code><code>.<\/code><code>1<\/code><code>\/dist\/solr<\/code><code>-<\/code><code><code>4.9<\/code><code>.<\/code><code>1<\/code><code><\/code>.war \/opt\/jetty\/webapps\/solr.war<\/code><\/div>\n<div>\n<div>\n<div><code>cp -a solr<\/code><code>-<\/code><code><code>4.9<\/code><code>.<\/code><code>1<\/code><code><\/code>\/example\/contexts\/solr-jetty-context.xml \/opt\/jetty\/webapps\/solr.xml<\/code><\/div>\n<div><code>cp -a solr<\/code><code>-<\/code><code><code>4.9<\/code><code>.<\/code><code>1<\/code><code><\/code><\/code><code>\/example\/lib\/ext\/* \/opt\/jetty\/lib\/ext\/<\/code><\/div>\n<div><\/div>\n<div>Extract the tarball of Solr to anywhere you like.<br \/>\n1tar zxvf solr-4.3.0-src.tgz -C \/tmpCopy the .war package to webapps directory of $JETTY_HOME, copy solr directory in the example\/ directory to a preferred directory as $SOLR_HOME, e.g \/opt. dist\/ and contrib\/ are also necessary.<\/p>\n<p>cp -a solr-4.3.0\/dist\/solr-4.3.0.war \/opt\/jetty\/webapps\/solr.war<br \/>\ncp -a solr-4.3.0\/example\/solr \/opt\/solr<br \/>\ncp -a solr-4.3.0\/dist \/opt\/solr<br \/>\ncp -a solr-4.3.0\/contrib \/opt\/solr<\/p>\n<p>Also, you will need the context and some modules to have Solr run properly on Jetty.<br \/>\ncp -a solr-4.3.0\/example\/contexts\/solr-jetty-context.xml \/opt\/jetty\/webapps\/solr.xml<br \/>\ncp -a solr-4.3.0\/example\/lib\/ext\/* \/opt\/jetty\/lib\/ext\/<\/p>\n<p>Add a line to the settings file of Jetty<br \/>\necho JAVA_OPTIONS=&#8221;-Dsolr.solr.home=\/opt\/solr $JAVA_OPTIONS&#8221; &gt;&gt; \/etc\/<\/p>\n<\/div>\n<div><\/div>\n<\/div>\n<\/div>\n<p>Solr is now one directory closer to Jetty than the default configuration shipped with Solr<\/p>\n<p># sudo nano solr\/solr\/collection1\/conf\/solrconfig.xml<\/p>\n<pre>&lt;!-- modify the path as following as we are a directory closer now --&gt;\n...\n&lt;lib dir=\"..\/..\/contrib\/extraction\/lib\" regex=\".*\\.jar\" \/&gt;\n&lt;lib dir=\"..\/..\/dist\/\" regex=\"solr-cell-\\d.*\\.jar\" \/&gt;\n\n&lt;lib dir=\"..\/..\/contrib\/clustering\/lib\/\" regex=\".*\\.jar\" \/&gt;\n&lt;lib dir=\"..\/..\/dist\/\" regex=\"solr-clustering-\\d.*\\.jar\" \/&gt;\n\n&lt;lib dir=\"..\/..\/contrib\/langid\/lib\/\" regex=\".*\\.jar\" \/&gt;\n&lt;lib dir=\"..\/..\/dist\/\" regex=\"solr-langid-\\d.*\\.jar\" \/&gt;\n\n&lt;lib dir=\"..\/..\/contrib\/velocity\/lib\" regex=\".*\\.jar\" \/&gt;\n&lt;lib dir=\"..\/..\/dist\/\" regex=\"solr-velocity-\\d.*\\.jar\" \/&gt;\n...\n\n&lt;!--  &lt;lib dir=\"\/non\/existent\/dir\/yields\/warning\" \/&gt; --&gt;\n\n<a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/solr1.jpg\"><img loading=\"lazy\" class=\"aligncenter size-full wp-image-2293\" alt=\"solr1\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/solr1.jpg\" width=\"193\" height=\"272\" \/><\/a> <a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/solr2.jpg\"><img loading=\"lazy\" class=\"aligncenter size-large wp-image-2294\" alt=\"solr2\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/solr2.jpg\" width=\"600\" height=\"514\" srcset=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/solr2.jpg 692w, http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/solr2-300x257.jpg 300w\" sizes=\"(max-width: 600px) 100vw, 600px\" \/><\/a> <a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/jetty1.jpg\"><img loading=\"lazy\" class=\"aligncenter size-large wp-image-2295\" alt=\"jetty1\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/jetty1.jpg\" width=\"582\" height=\"702\" srcset=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/jetty1.jpg 582w, http:\/\/www.extradrm.com\/wp-content\/uploads\/2015\/01\/jetty1-248x300.jpg 248w\" sizes=\"(max-width: 582px) 100vw, 582px\" \/><\/a><\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to Deploy Solr 4.3 On Jetty&nbsp;9 https:\/\/www.digitalocean.com\/community\/tutorials\/how-to-install-solr-on-ubuntu-14-04 http:\/\/hollysydney.com\/article\/solr-4-jetty-9-and-search-api-ubuntu http:\/\/pietervogelaar.nl\/ubuntu-12-04-install-solr-4-with-jetty-9 http:\/\/zetcode.com\/java\/jetty\/install\/ 1- Install openjdk Jetty 9 requires JDK 7, so if you don\u2019t have it installed, install it first. In Ubuntu, it is very&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":2847,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"youtube_video":null,"_links":{"self":[{"href":"http:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/posts\/2272"}],"collection":[{"href":"http:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2272"}],"version-history":[{"count":0,"href":"http:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/posts\/2272\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/media\/2847"}],"wp:attachment":[{"href":"http:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2272"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2272"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2272"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}