Running two instances of Solr on Tomcat on one Ubuntu server.

This post deals specifically with the aptitude packages tomcat6 and solr-tomcat, but it might be helpful in general. You can basically copy and paste the following (as root):

cp /etc/tomcat6/Catalina/localhost/solr.xml /etc/tomcat6/Catalina/localhost/solr_2.xml
nano /etc/tomcat6/Catalina/localhost/solr_2.xml

Make it look like this:

<Context path="/solr_2" docBase="/usr/share/solr_2"
 debug="0" privileged="true" allowLinking="true" crossContext="true">
 <Resources className="org.apache.naming.resources.FileDirContext" allowLinking="true" />
 <Environment name="solr/home" type="java.lang.String" value="/usr/share/solr_2" override="true" />
</Context>

Then:

cp -rf /usr/share/solr /usr/share/solr_2
cp -rf /etc/solr /etc/solr_2
rm /usr/share/solr_2/WEB-INF/web.xml
ln -s /etc/solr_2/web.xml /usr/share/solr_2/WEB-INF/web.xml
rm /usr/share/solr_2/conf
ln -s /etc/solr_2/conf /usr/share/solr_2/conf
nano /etc/solr_2/conf/solrconfig.xml
cp -rf /var/lib/solr /var/lib/solr_2
chown -R tomcat6:tomcat6 /var/lib/solr_2/data
chmod -R 770 /var/lib/solr_2/data
chown tomcat6:tomcat6 dataimport.properties
service tomcat6 restart

Now you should have two solr instances running at localhost:8080/solr and localhost:8080/solr_2 respectively.