05. Setting up solr - findsorguk/findsorguk GitHub Wiki
The system relies on Solr for the search indices and for the fast and efficient running. To get this working, naturally, you will need to have Solr installed on your box but also an installation of Tomcat 7: follow these instructions to install Tomcat.
Got Tomcat on your machine? The next thing is to set up a user so that you can log into the admin page.
sudo nano /etc/tomcat7/tomcat-users.xml
and add the following within the <tomcat-users> tags:
<user username="admin" password="password" roles="manager-gui,admin-gui"/>
then,
sudo service tomcat7 restart
Now we can press on with installing Solr. Take your time and follow these instructions to the letter; it is easy to go astray with this!
To begin, we're going to create a directory in /var to store the solr files, so do the following:
sudo mkdir /var/solr
Now, we're going to download the source files.
cd /var/solr
sudo wget https://archive.apache.org/dist/lucene/solr/4.2.1/solr-4.2.1.zip
sudo unzip solr-4.2.1.zip
Note the version - it must be 4.2.1.
Now we're going to create a couple of directories to hold everything:
sudo mkdir lib solr
and copy the solr library files in. We're going to take these from the example folder:
sudo cp solr-4.2.1/example/lib/* lib
There are two more files needed to connect to MYSQL. We'll use wget to get these and then remove folders we do not need:
cd lib
sudo wget http://central.maven.org/maven2/org/apache/solr/solr-dataimporthandler/4.2.1/solr-dataimporthandler-4.2.1.jar
sudo wget https://dev.mysql.com/get/archives/mysql-connector-java-5.1/mysql-connector-java-5.1.23.zip
sudo unzip mysql-connector-java-5.1.23.zip
sudo mv mysql-connector-java-5.1.23/mysql-connector-java-5.1.23.jar ../
rm -R mysql-connector-java-5.1.23
rm mysql-connector-java-5.1.23.zip
If that isn't there (though I'm not sure why it wouldn't!) you can also find it in: /var/solr/solr-4.2.1/dist
OK, that's the library files taken care of. Let's get the war file in place.
cd /var/solr
sudo cp solr-4.2.1/dist/solr-4.2.1.war solr.war
Next, we can get some finds.org setup files and place them in their correct location:
sudo git clone https://github.com/findsorguk/findsorguk-solr.git findsorguk
sudo cp findsorguk/solr.xml.template solr.xml
We now need to tell tomcat about the war file so begin by editing this configuration file:
sudo nano /var/lib/tomcat7/conf/Catalina/localhost/solr.xml
and within that, place the following:
<?xml version="1.0" encoding="utf-8"?>
<Context docBase="/var/solr/solr.war" debug="0" crossContext="true" >
<Environment name="solr/home" type="java.lang.String" value="/var/solr" override="true" />
</Context>
Almost done. All that is left is to make sure that Tomcat can access everything so make sure you are back in the root folder in the solr directory (you should already be):
cd /var/solr
sudo chown -R tomcat7:tomcat7 *
and of course, restart the server.
sudo service tomcat7 restart
If all has gone well, you should be able to visit your Tomcat admin page and then click on the Solr installation.
http://localhost:8080/manager/html
Clicking on: /solr
If this has worked, you should see a beautiful solr admin page with the Apache Solr logo in the top left.
If you have multiple solr hosts, you can configure replication by following these instructions
You now need to configure the vhosts if you are planning on doing this.