Installing ApacheSolr on Ubuntu

22 Jul 2014 Installing ApacheSolr on Ubuntu

You aren’t alone I had to scower the internet and read several articles before I truly understand all of this. If you are using Debian/Ubuntu (with Tomcat7) it’s even easier then most outline. I preferred this over Lullabot since when you install it through Ubuntu it’s actually a service and less fiddling 🙂

Install Java

apt-get install java7-jdk

Install Tomcat

apt-get install tomcat7 tomcat7-admin

Once this is done you can get to http://localhost:8080 and see that’s it is all running properly.

Note: It’s recommended to push the port to another one since 8080 is pretty common. If you want to do that use this code for that!

sudo sed -i s/8080/8983/g /var/lib/tomcat7/conf/server.xml

Configure Tomcat

You will want to actually create a users account for Tomcat so that other people have to log into the admin (it keeps it safer).

Now you can restart tomcat again and view the admin page at http://localhost:8983/manager/html OR service tomcat7 restart

Install Solr

Download the latest Apache here (When I wrote this I got it working with 4.7)

Extract the files into a directory

Copy Solr library files

Next we want to add the library files to Tomcat library directory. Note: You can also use symlinks if you prefer, but for the purpose of understand where everything goes I chose to place it directly in the directories.

cp ~/solr-4.x.x/example/lib/ext/* /usr/share/tomcat7/lib/

It may be a good idea to also copy the java libraries from solr/dist/solrrj-lib/*

cp ~/solr-4.x.x/dist/solrj-lib/* /usr/local/tomcat7/lib/

Copy Solr WAR app file

cp ~/solr-4.x.x/dist/solr-4.x.x.war /var/lib/tomcat7/webapps/solr.war

Setup Drupal ApacheSolr core

We first need to copy over the sample configuration files from ApacheSolr.mkdir -p /var/lib/tomcat7/solr cp -r ~/solr-4.x.x/example/solr/collection1/conf /var/lib/tomcat7/solr/

Next grab the latest version of the apachesolr module https://drupal.org/project/apachesolr and unzip ittar xvf apachesolr-*.tar.gz

Note: I found an error in which ApacheSolr refused to start due to duplicate errors. I reported that here so you might want to look at the solution here as at the time of writing this I could not get it running without that!

Create Drupal core directory

This will create a new core in your system with that name. If you wish to add more you simply can repeat this step as well as the one above. mkdir /var/lib/tomcat7/solr/!!yourcoredir!! cp -r /var/lib/tomcat7/solr/conf /var/lib/tomcat7/solr/!!yourcoredir!!/

Let’s Make It Live

Your at the last stretch!! Let’s put tomcat7 to sleep service tomcat7 stop

Now change the permissions on the tomcat directory chown -R tomcat7:tomcat7 /var/lib/tomcat7

Start it back up service tomcat7 start

It’s Live

You should be able to go to <code>http://localhost:8983/solr</code> and see a new core instance available! Now you can go ahead and configure drupal to point to that.

Note:Your new core is located at <code>http://localhost:8983/solr/!!yourcorename!!</code> to be used in the Drupal ApacheSolr module.

Shane Bill has been working in the web consulting industry for well over 20 years. He is passionate about the empowerment of community organizations, individuals, and businesses in being able to reach their goals through online tools. Shane’s experience has led him to help build greater cloud infrastructure, system support, revamped websites, and much more. He is passionate about keeping up-to-date on the latest technology changes, and helping others advance their projects through this knowledge! Shane contributes frequently to various online FAQ sections and Drupal modules to help others reach their goals and resolve issues.