
After a long break, I decided to write another article about apache solr and drupal. This time it will be about setting up tomcat so that apache solr can work like a daemon. There are already many different tomcat tutorials on the Internet, but they are not always suitable for working with drupal. In particular, I configured tomcat and apache solr worked fine. But after I changed the standard Solr configs to the Drupal configs, Solr stopped working (java exceptions started to take off).
So let's get down to business.
My configuration
Ubuntu server 12.04
Apache solr 3.6.1
Drupal 7
Search modules -
search api and
search_api_solrAnd now the installation
Install tomcat
')
sudo apt-get install tomcat6
Download and unpack apache solr in a temporary directory
mkdir /tmp/solr/ cd /tmp/solr/ wget http://archive.apache.org/dist/lucene/solr/3.6.1/apache-solr-3.6.1.tgz tar xzvf apache-solr-3.6.1.tgz
Then we create a directory in which it will work on the Apache solr server and copy the necessary files there.
sudo mkdir /var/solr war sudo cp apache-solr-3.6.1/dist/apache-solr-3.6.1.war /var/solr/solr.war . sudo cp -R apache-solr-3.6.1/example/multicore/* /var/solr/ sudo chown -R tomcat6 /var/solr/
We connect tomcat with our Apache solr server
echo -e '<Context docBase="/var/solr/solr.war" debug="0" privileged="true" allowLinking="true" crossContext="true">\n<Environment name="solr/home" type="java.lang.String" value="/var/solr" override="true" />\n</Context>' | sudo tee -a /etc/tomcat6/Catalina/localhost/solr.xml echo 'TOMCAT6_SECURITY=no' | sudo tee -a /etc/default/tomcat6
Now in the / etc / default / tomcat6 file you need to specify the solr home directory - / var / solr. To do this, edit the parameter JAVA_OPTS
sudo nano /etc/default/tomcat6
And expose there:
JAVA_OPTS="$JAVA_OPTS -Dsolr.home=/var/solr"
After that, reboot tomcat:
sudo /etc/init.d/tomcat6 restart
We are convinced that everything works, for this you can go to url
localhost : 8080 / solr /
If successful, you should see something like this.

By default, there are already two cores, but in order to be able to use the config and the scheme from search_api for Drupal, we will create a new kernel.
First we enter it into /var/solr/solr.xml
At the end of the file, the kernels are described, in my case, after adding the kernel, the config looks like this:
<solr persistent="false"> <cores adminPath="/admin/cores"> <core name="core0" instanceDir="core0" /> <core name="core1" instanceDir="core1" /> <core name="drupal" instanceDir="drupal" /> </cores> </solr>
Then copy the files from the downloaded apache solr for our kernel that will work with Drupal.
sudo mkdir /var/solr/drupal sudo cp -R /tmp/solr/apache-solr-3.6.1/example/solr/* /var/solr/drupal
We put the config and the scheme from the search_api_solr module there
Restart tomcat again with the command
sudo /etc/init.d/tomcat6 restart
Set Solr settings in Drupal

Now we index the content and enjoy the job search!
Articles seem to be good, but the activity is not enough. In some articles from this cycle there are not even comments, suddenly nobody is interested? I will be glad to constructive comments in the comments.