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).
nano /var/lib/tomcat7/conf/tomcat-users.xml
- Then add these xml arguments between the
<tomcat-users>
tags add the following:
<role rolename="manager-gui"/>
<role rolename="admin-gui"/>
<user username="!!somename!!" password="!!somepassword!!" roles="manager-gui,admin-gui"/>
- Now you can restart tomcat again and view the admin page at
http://localhost:8983/manager/html
ORservice 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 it
tar xvf apachesolr-*.tar.gz
- Syncronize the apachesolr configuration files (for Drupal) with your solr configuration
rsync -av apachesolr/solr-conf/solr-4.x/ /var/lib/tomcat7/solr/conf/
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 a core definition file to tell Apache Solr which cores are available.
nano /var/lib/tomcat7/solr/solr.xml
- Paste the following code inside that file
<?xml version="1.0" encoding="UTF-8" ?>
<solr persistent="false">
<cores adminPath="/admin/cores">
<core name="!!yourcorename!!" instanceDir="!!yourcoredir!!" />
</cores>
</solr>
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.
If you find this useful you can Up my posting on StackExchange!
Credit and props goes out to Pacoup for the start of this discussion