{"id":3529,"date":"2016-03-30T02:17:27","date_gmt":"2016-03-30T02:17:27","guid":{"rendered":"http:\/\/www.garysieling.com\/blog\/?p=3529"},"modified":"2016-03-30T02:17:27","modified_gmt":"2016-03-30T02:17:27","slug":"install-solr-ubuntu","status":"publish","type":"post","link":"https:\/\/www.garysieling.com\/blog\/install-solr-ubuntu\/","title":{"rendered":"Install Solr on Ubuntu"},"content":{"rendered":"<p>First, you need a JDK.<\/p>\n<p>I ran this:<\/p>\n<pre lang=\"bash\">\napt-get install openjdk-7-jdk\n<\/pre>\n<p>You can also use the Oracle JDK, but it requires signing an additional license. It also seems to involve a more convoluted installation (they make JAVA_HOME point to a symlink to the JDK, which changes as you upgrade).<\/p>\n<p>For me, this JDK was installed here (you may want to note this):<br \/>\n\/usr\/lib\/jvm\/java-7-openjdk-i386\/<\/p>\n<p>Before running the solr installation steps, go to the Solr download page, and find the current version.<\/p>\n<pre lang=\"bash\">\nsudo su root\ncd ~\nwget http:\/\/apache.arvixe.com\/lucene\/solr\/5.5.0\/solr-5.5.0.tgz\ntar xzf solr-5.5.0.tgz solr-5.5.0\/bin\/install_solr_service.sh --strip-components=2\nsudo chmod +x install_solr_service.sh\nsudo .\/install_solr_service.sh solr-5.5.0.tgz\n<\/pre>\n<p>To run solr, you should then be able to run this:<\/p>\n<pre lang=\"bash\">\nservice solr start\n<\/pre>\n<p>However, this may not work at first.<\/p>\n<p>If you get an error that it can&#8217;t find the JDK:<\/p>\n<pre lang=\"bash\">\nThe currently defined JAVA_HOME (\/usr\/lib\/jvm\/java-8-oracle) refers\nto a location where Java could not be found.  Aborting.\nEither fix the JAVA_HOME variable or remove it from the\nenvironment so that the system PATH will be searched.\n<\/pre>\n<p>If this happens, do:<\/p>\n<pre lang=\"bash\">\nvi \/etc\/default\/solr.in.sh\n<\/pre>\n<p>And add this line (using the path you saved above):<\/p>\n<pre lang=\"bash\"> \nSOLR_JAVA_HOME=\"\/usr\/lib\/jvm\/java-7-openjdk-i386\"\n<\/pre>\n<p>If you get a permissions denied error on \/dev\/null:<\/p>\n<pre lang=\"bash\">\n\/opt\/solr\/bin\/solr: line 120: \/dev\/null: Permission denied\nJava not found, or an error was encountered when running java.\nA working Java 7 or later is required to run Solr!\nPlease install Java or fix JAVA_HOME before running this script.\nCommand that we tried: '\/usr\/lib\/jvm\/java-7-openjdk-i386\/bin\/java -version'\nActive Path:\n\/usr\/local\/bin:\/usr\/bin:\/bin:\/usr\/local\/games:\/usr\/games:\/usr\/lib\/jvm\/java-8-oracle\/bin:\/usr\/lib\/jvm\/java-8-oracle\/db\/bin:\/usr\/lib\/jvm\/java-8-oracle\/jre\/bin\n<\/pre>\n<p>This indicates that \/dev\/null is a file, rather than a device. Run this:<\/p>\n<pre lang=\"bash\">\nrm \/dev\/null\nmknod \/dev\/null c 1 3\nchmod 666 \/dev\/null\n<\/pre>\n<p>Once you do this, solr should work.<\/p>\n<p>However, you then should consider disabling external access, since the UI has no security.<\/p>\n<p>The best way to do this is with firewall rules, since this blocks network traffic (make sure you take a snapshot of your virtual machine before you tinker with iptables, because you can lock yourself out)<\/p>\n<pre lang=\"bash\">\nsudo iptables -A INPUT -p tcp -s localhost --dport 8983 -j ACCEPT\nsudo iptables -A INPUT -p tcp --dport 8983 -j DROP\n<\/pre>\n<p>If the above causes you a problem, you can still get out by rebooting.<\/p>\n<p>This makes it permanent:<\/p>\n<pre lang=\"bash\">\n\/sbin\/iptables-save\n<\/pre>\n<p>Another option is to <a href=\"http:\/\/stackoverflow.com\/questions\/8924102\/restricting-ip-addresses-for-jetty-and-solr\">limit access to your IP address, <\/a> although if your IP changes frequently this is not ideal, and it risks you losing the setting if you upgrade.<\/p>\n<p>Alternately, since Solr by default runs on Jetty, you can restrict access to only the loopback address<sup><a href=\"#footnote_1_3529\" id=\"identifier_1_3529\" class=\"footnote-link footnote-identifier-link\" title=\"http:\/\/stackoverflow.com\/questions\/1955455\/how-to-secure-jetty-to-only-allow-access-from-loopbacklocalhost\">1<\/a><\/sup>. The disadvantage of doing this through Jetty is that it assumes you trust Solr not to open more ports without your awareness.<\/p>\n<p>If you go the firewall route, a handy option is SSH port forwarding, which will allow you to access the solr UI when you SSH into the box. <\/p>\n<p>If you use Putty this means adding \u201c-L 8983:localhost:8983\u201d to the command line arguments. Once you connect this way, you can use \u201chttp:\/\/localhost:8983\/solr\/#\/\u201d to connect to the Solr admin panel.<\/p>\n<p><b>Logging<\/b><br \/>\nYou may also want to check the log settings. By default log rotation appears to be enabled correctly, although the file size is a bit small:<\/p>\n<p>File: \/opt\/solr\/server\/resources\/log4j.properties<\/p>\n<pre>\nlog4j.appender.file=org.apache.log4j.RollingFileAppender\nlog4j.appender.file.MaxFileSize=4MB\nlog4j.appender.file.MaxBackupIndex=9\n<\/pre>\n<ol class=\"footnotes\"><li id=\"footnote_1_3529\" class=\"footnote\">http:\/\/stackoverflow.com\/questions\/1955455\/how-to-secure-jetty-to-only-allow-access-from-loopbacklocalhost<span class=\"footnote-back-link-wrapper\"> [<a href=\"#identifier_1_3529\" class=\"footnote-link footnote-back-link\">&#8617;<\/a>]<\/span><\/li><\/ol>","protected":false},"excerpt":{"rendered":"<p>Guide for installing solr on Ubuntu<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"footnotes":""},"categories":[12],"tags":[300,517,559],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.9 - aioseo.com -->\n\t<meta name=\"description\" content=\"Guide for installing solr on Ubuntu\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"gary\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/www.garysieling.com\/blog\/install-solr-ubuntu\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.9\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Gary Sieling - Software Engineer\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Install Solr on Ubuntu - Gary Sieling\" \/>\n\t\t<meta property=\"og:description\" content=\"Guide for installing solr on Ubuntu\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/www.garysieling.com\/blog\/install-solr-ubuntu\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2016-03-30T02:17:27+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2016-03-30T02:17:27+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Install Solr on Ubuntu - Gary Sieling\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Guide for installing solr on Ubuntu\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BlogPosting\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/install-solr-ubuntu\\\/#blogposting\",\"name\":\"Install Solr on Ubuntu - Gary Sieling\",\"headline\":\"Install Solr on Ubuntu\",\"author\":{\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/author\\\/gary\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/#organization\"},\"datePublished\":\"2016-03-30T02:17:27+00:00\",\"dateModified\":\"2016-03-30T02:17:27+00:00\",\"inLanguage\":\"en-US\",\"commentCount\":4,\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/install-solr-ubuntu\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/install-solr-ubuntu\\\/#webpage\"},\"articleSection\":\"How-To, java, solr, ubuntu\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/install-solr-ubuntu\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.garysieling.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/category\\\/how-to\\\/#listItem\",\"name\":\"How-To\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/category\\\/how-to\\\/#listItem\",\"position\":2,\"name\":\"How-To\",\"item\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/category\\\/how-to\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/install-solr-ubuntu\\\/#listItem\",\"name\":\"Install Solr on Ubuntu\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/install-solr-ubuntu\\\/#listItem\",\"position\":3,\"name\":\"Install Solr on Ubuntu\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/category\\\/how-to\\\/#listItem\",\"name\":\"How-To\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/#organization\",\"name\":\"Gary Sieling\",\"description\":\"Software Engineer\",\"url\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/author\\\/gary\\\/#author\",\"url\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/author\\\/gary\\\/\",\"name\":\"gary\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/install-solr-ubuntu\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0be925276d848ffe98a6a9dc8cf33e67?s=96&d=identicon&r=g\",\"width\":96,\"height\":96,\"caption\":\"gary\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/install-solr-ubuntu\\\/#webpage\",\"url\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/install-solr-ubuntu\\\/\",\"name\":\"Install Solr on Ubuntu - Gary Sieling\",\"description\":\"Guide for installing solr on Ubuntu\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/install-solr-ubuntu\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/author\\\/gary\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/author\\\/gary\\\/#author\"},\"datePublished\":\"2016-03-30T02:17:27+00:00\",\"dateModified\":\"2016-03-30T02:17:27+00:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/\",\"name\":\"Gary Sieling\",\"description\":\"Software Engineer\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.garysieling.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Install Solr on Ubuntu - Gary Sieling","description":"Guide for installing solr on Ubuntu","canonical_url":"https:\/\/www.garysieling.com\/blog\/install-solr-ubuntu\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BlogPosting","@id":"https:\/\/www.garysieling.com\/blog\/install-solr-ubuntu\/#blogposting","name":"Install Solr on Ubuntu - Gary Sieling","headline":"Install Solr on Ubuntu","author":{"@id":"https:\/\/www.garysieling.com\/blog\/author\/gary\/#author"},"publisher":{"@id":"https:\/\/www.garysieling.com\/blog\/#organization"},"datePublished":"2016-03-30T02:17:27+00:00","dateModified":"2016-03-30T02:17:27+00:00","inLanguage":"en-US","commentCount":4,"mainEntityOfPage":{"@id":"https:\/\/www.garysieling.com\/blog\/install-solr-ubuntu\/#webpage"},"isPartOf":{"@id":"https:\/\/www.garysieling.com\/blog\/install-solr-ubuntu\/#webpage"},"articleSection":"How-To, java, solr, ubuntu"},{"@type":"BreadcrumbList","@id":"https:\/\/www.garysieling.com\/blog\/install-solr-ubuntu\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/www.garysieling.com\/blog#listItem","position":1,"name":"Home","item":"https:\/\/www.garysieling.com\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/www.garysieling.com\/blog\/category\/how-to\/#listItem","name":"How-To"}},{"@type":"ListItem","@id":"https:\/\/www.garysieling.com\/blog\/category\/how-to\/#listItem","position":2,"name":"How-To","item":"https:\/\/www.garysieling.com\/blog\/category\/how-to\/","nextItem":{"@type":"ListItem","@id":"https:\/\/www.garysieling.com\/blog\/install-solr-ubuntu\/#listItem","name":"Install Solr on Ubuntu"},"previousItem":{"@type":"ListItem","@id":"https:\/\/www.garysieling.com\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/www.garysieling.com\/blog\/install-solr-ubuntu\/#listItem","position":3,"name":"Install Solr on Ubuntu","previousItem":{"@type":"ListItem","@id":"https:\/\/www.garysieling.com\/blog\/category\/how-to\/#listItem","name":"How-To"}}]},{"@type":"Organization","@id":"https:\/\/www.garysieling.com\/blog\/#organization","name":"Gary Sieling","description":"Software Engineer","url":"https:\/\/www.garysieling.com\/blog\/"},{"@type":"Person","@id":"https:\/\/www.garysieling.com\/blog\/author\/gary\/#author","url":"https:\/\/www.garysieling.com\/blog\/author\/gary\/","name":"gary","image":{"@type":"ImageObject","@id":"https:\/\/www.garysieling.com\/blog\/install-solr-ubuntu\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/0be925276d848ffe98a6a9dc8cf33e67?s=96&d=identicon&r=g","width":96,"height":96,"caption":"gary"}},{"@type":"WebPage","@id":"https:\/\/www.garysieling.com\/blog\/install-solr-ubuntu\/#webpage","url":"https:\/\/www.garysieling.com\/blog\/install-solr-ubuntu\/","name":"Install Solr on Ubuntu - Gary Sieling","description":"Guide for installing solr on Ubuntu","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/www.garysieling.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/www.garysieling.com\/blog\/install-solr-ubuntu\/#breadcrumblist"},"author":{"@id":"https:\/\/www.garysieling.com\/blog\/author\/gary\/#author"},"creator":{"@id":"https:\/\/www.garysieling.com\/blog\/author\/gary\/#author"},"datePublished":"2016-03-30T02:17:27+00:00","dateModified":"2016-03-30T02:17:27+00:00"},{"@type":"WebSite","@id":"https:\/\/www.garysieling.com\/blog\/#website","url":"https:\/\/www.garysieling.com\/blog\/","name":"Gary Sieling","description":"Software Engineer","inLanguage":"en-US","publisher":{"@id":"https:\/\/www.garysieling.com\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"Gary Sieling - Software Engineer","og:type":"article","og:title":"Install Solr on Ubuntu - Gary Sieling","og:description":"Guide for installing solr on Ubuntu","og:url":"https:\/\/www.garysieling.com\/blog\/install-solr-ubuntu\/","article:published_time":"2016-03-30T02:17:27+00:00","article:modified_time":"2016-03-30T02:17:27+00:00","twitter:card":"summary_large_image","twitter:title":"Install Solr on Ubuntu - Gary Sieling","twitter:description":"Guide for installing solr on Ubuntu"},"aioseo_meta_data":{"post_id":"3529","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"created":"2023-02-04 16:45:44","updated":"2026-07-06 01:41:39","ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.garysieling.com\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.garysieling.com\/blog\/category\/how-to\/\" title=\"How-To\">How-To<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tInstall Solr on Ubuntu\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/www.garysieling.com\/blog"},{"label":"How-To","link":"https:\/\/www.garysieling.com\/blog\/category\/how-to\/"},{"label":"Install Solr on Ubuntu","link":"https:\/\/www.garysieling.com\/blog\/install-solr-ubuntu\/"}],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/3529"}],"collection":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/comments?post=3529"}],"version-history":[{"count":0,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/3529\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/media?parent=3529"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/categories?post=3529"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/tags?post=3529"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}