Tomcat and Solr on EC2

15 Apr 2012

First of all, install `tomcat`. You can choose your own version.

yum install tomcat7

Now we need to install Solr manually. Let's first download it:

wget http://mirrors.issp.co.th/apache/lucene/solr/3.6.0/apache-solr-3.6.0.tgz

Unpack it, and make the new folder `solr`. Then, we just need to properly place all the files in this folder:

cp -R apache-solr-3.6.0/example/solr/* /solr cp apache-solr-3.6.0/dist/apache-solr-3.6.0.war /solr/solr.war

Now let's configure Tomcat to point at this. Create a file with `vi`.

vi /etc/tomcat7/Catalina/localhost/solr.xml

Then place this text inside:

<Context docBase="/solr/solr.war" debug="0" privileged="true" allowLinking="true" crossContext="true"> <Environment name="solr/home" type="java.lang.String" value="/solr" override="true" /> </Context>

Let `tomcat` user access the folder.

chown -R tomcat:tomcat /solr

Now copy you `schema.xmland place it in ``/solr/conf/schema.xml`. (Or make a symbolic linkln -s &lt;your schema.xml> /solr/conf/schema.xml``)

And also edit `/solr/conf/solrconfig.xml`. Fix the data path:

<dataDir>${solr.data.dir:/solr/data}</dataDir>

and also fix all the `lib` tags in it.

Now restart Tomcat with `/etc/init.d/tomcat7 restart`.

That's it.

Give it a kudos