This page details how to set up Apache Solr version 5.x for use with the Search API Solr Search module.
Basic setup
As a pre-requisite for running your own Solr server, you'll need Java Runtime version 7 or higher.
Download the latest version of Solr and unpack the archive somewhere outside of your web server's document tree.
Solr 5.x comes with a fully-fledged Java web server for running it, so you won't need to install Tomcat or Jetty anymore even for advanced setups.
Caution! For production sites, it is vital that you somehow prevent outside access to the Solr server. Otherwise, attackers could read, corrupt or delete all your indexed data. Using the example server WON'T prevent this by default. If it is available, the probably easiest way of preventing this is to disable outside access to the ports used by Solr through your server's network configuration or through the use of a firewall.
Other options include adding basic HTTP authentication or renaming the solr/
directory to a random string of characters and using that as the path.
Config files
Before starting the Solr server you will have to make sure it uses the proper configuration files. These are located in the solr-conf/5.x
directory in this module. Create a new folder structure in your Solr installation directory with the path server/solr/drupal/conf
and copy all configuration files there. ("drupal" in this case is the core name, and can be freely chosen.)
Note:
Themapping-ISOLatin1Accent.txt
file is only included in the module for completeness' sake, as it is required to start the Solr server. It will be usually advisable to just use the file from one of Solr's example applications (located in "server/solr/configsets/sample_techproducts_configs") in this case, though, as it contains really useful definitions, while the file provided with this module is empty, apart from some documentation. For licensing reasons, it is not possible for us to include the definitions in the example config file in the copy this module provides.
Caution!
For production sites, it is vital that you somehow prevent unauthorized access to the Solr server. Otherwise, attackers could read, corrupt or delete all your indexed data.
If you Solr is installed on the same machine as Drupal, the probably easiest way to do this is by blocking all outside access. Similarly, you can only allow access from the IP address of your Drupal web server.
The best way to implement this, if you have access to it, is by using the operating system's own network configuration or by installing and configuring a firewall. If this is not possible, then the Solr web server also provides a way to specify which IPs should be allowed to access it, by adding anIPAccessHandler
toserver/etc/jetty.xml
as described here.
Other, advanced methods for securing the Solr server can be found in the Solr wiki.IPv6
If your server supports IPv6, the Jetty IPAccessHandler configuration of127.0.0.1
might not work as localhost will be resolved as::1
(in the solr logs you will see 0:0:0:0:0:0:0:1). In order to overcome this problem you should be able to whitelist the IPv6 address for localhost as well (assumed, not tested) or change the Drupal solr host to127.0.0.1
rather thenlocalhost
.
Running Solr
You can then start Solr. Open a command line/terminal in the root directory of the Solr installation and then issue the following command:
bin/solr start
Or, if you are on Windows:
bin\solr.cmd start
This will start the Solr web server on the default port (8983) in the background and write the logs to server/logs/solr-8983-console.log
.
Afterwards, go to the Solr admin screen in your web browser. Click on "Core Admin" and then on "Add Core". Put in your core name (drupal
in the above example)
as both "name" and "instanceDir" and submit. You should now have a new Solr core ready to use for your Drupal site.
(If you don't have access to the Solr admin UI, you can also add a new core by running bin/solr create -c drupal -d server/solr/drupal
. If you are root make sure you are sudoing to solr like this: sudo -u solr bin/solr create -c collection1 -d server/solr/collection1
)
You can then enable this module and create a new server, using the "Solr search" service class. Enter the hostname, port and path corresponding to your Solr server in the appropriate fields. The default values already correspond to the installation above, you will just have to append the core name you've chosen to the path. E.g., for the above instructions, use "/solr/drupal" instead of "/solr". If you are using HTTP Authentication to protect your Solr server you also have to provide the appropriate user and password here.
Making Solr start automatically
You will have to execute the above command each time after you restart your machine for Solr to be available. To avoid this, you can install Solr as a service on your machine with the following command (inside you Solr installation folder):
bin/install_solr_service.sh
(This is currently supported for Ubuntu, Debian, Red Hat and SUSE Linux – other Linux distributions will output an error message, and there is no automatic way provided for Windows. Search on the internet to find out how to set up autostart of Solr on your system.)
By default, when installed in this way, Solr looks for core files in /var/solr. To have the Drupal core in server/solr/drupal discovered, the best way is to create a symlink:
ln -s <solr_installation_folder>/server/solr/drupal /var/solr/data/drupal
Drupal 7 Note: Solr versions 5.5 and higher is incompatible with Search API Solr module (in the 5.x). Please use Solr 5.4.1 version.
However, there is a bug in Solr 5.4 and previous versions that prevents Solr from following the symlink, you can apply this patch.
Comments
I don't see any solr-conf/5.x
I don't see any solr-conf/5.x the latest us solr-conf/4.x
i can see it here http://cgit
i can see it here http://cgit.drupalcode.org/search_api_solr/tree/solr-conf?id=7.x-1.7
Please use the last version of https://www.drupal.org/project/search_api_solr (that's 7.x-1.7)
Twitter: @ismaeil_
Solr 5.2
Just a note that solrcore.properties in 5.0 becomes core.properties in 5.2. Change the name of your file and you should be fine.
Make sure you don't download
Make sure you don't download the src.tgz file unless you feel like compiling java...
......................................................................................................
Marton Bodonyi
http://www.codesidekick.com
.........................................................
I found this good article
I found this good article about installing Solr 5.x with Drupal 7 in Centos http://www.webfoobar.com/node/16. I just like to share it with you guys.
Docker images
Hi!
I've created two Docker images, these could be very handy, if you don't want to deal with the Solr configuration:
Apache Solr 4.x for Drupal search (with partial search support)
https://registry.hub.docker.com/u/mxr576/apachesolr-4.x-drupal-docker/
Apache Solr 5.x for Drupal search
https://registry.hub.docker.com/u/mxr576/apachesolr-5.x-drupal-docker/
Feel free to use or fork them!
Config file also works for the Apache Solr module?
Hi, from this post https://www.drupal.org/node/2442077 it seems that drunken monkey and Nick_vh were working on the configuraiton files for Solr 5.x together.
Does that mean that this configuration file also works for the Drupal 7 version of the Apache Solr module that Nick_vh maintains? I want to be sure that it should work before I allocate resources to create a VM to try it out. I do not see any indication that Nick_vh has added the configuration file for Solr 5.x into the Apache Solr module.
Thanks!
Follow up to 5.x in Apache Solr Module
Hi All,
I went ahead and gave it a try since it seemed I might not get a response and verified that the 5.x configuration files in the Solr Search Api module also work for the Apache Solr Module.
Other tutorial
https://www.digitalocean.com/community/tutorials/how-to-install-solr-5-2...
This seems quite helpful and up-to-date..
Turns out when following the
Turns out when following the digitalocean tutorial I just linked to, the "Solr path" configured in Drupal needs to be "/solr/gettingstarted" or "/solr/corename", not just "/solr".
IBM JVM and Solr 5.4.x
I wrote this post in hope that it will help some poor souls somewhere, sharing the same pain that we endure with the following setup. Here's the short version: If you have all kinds of bizarre errors (can't find class files or xml files), move (only) your core.properties file one level up, at the same level of the "conf" directory. And here's the long version... We were running 5 servers (Suse SLES 12 on VMware) using Oracle JVM (1.7.0_85) and Solr 5.3.1. EVERYTHING was working fine following those clear instructions except for ONE machine. It was a bit puzzling because our deployment was made with Ansible playbook and only one machine refuse to work (the problem: failure of drupal to query solr but everything else was ok, like indexing or adding content!?). After many manual test and investigation we were getting no where. We suggest to IT operator to simply rebuild the machine but this seems like asking for too much. After couple of weeks, they got back to us with a strange solution... change JVM!?!? So they installed JVM from IBM (1.7.0) on the faulty server and strangely enough it work!? BUT, being a DevOps "fan", I suggest that we test this NEW solution on a server that was already working from scratch i.e. re-running the Ansible playbook on this machine with the "updated" JVM. Result? The already working server stopped to work!!! (Either the bin/solr status was printing java dump or admin web app showing errors about finding elevate.xml files). What was going on? After analyzing Solr logs, one pattern was clear: the initialization process was not finding is files in the right place. Their was errors showing ../conf/conf/... path and analyzing the relative path of solr.contrib.dir in the original files from the tar (in solr-conf/5.x) showed that the file was in the wrong place (../../../contrib is still one level short). Moving the file up and restarting the server solved the problem! We did the same setup (thru Ansible) on the others servers and everything was back to "normal". Hope this help!
thanks stevesirois, you saved
thanks stevesirois, you saved me some hard time :)
figureslibres.cc
Solr 5 installs in
Solr 5 installs in
/opt/solr-5.5.0/server/solr
and puts the data at
/var/solr/data/COLLECTIONNAME/conf
Should I put the config files at
/opt/solr-5.5.0/server/solr/COLLECTIONNAME/conf
Or at
/var/solr/data/COLLECTIONNAME/conf
I also see a folder at
/opt/solr-5.5.0/server/solr/configsets
My Drupal sites:
/var/solr/data/COLLECTIONNAME
/var/solr/data/COLLECTIONNAME/conf
Also ran into this issue when
Also ran into this issue when setting up ther server... #2127555: Can't Index Items: 400 Status, Bad Request
My Drupal sites:
chown solr:solr for /var/solr/data/drupal
FYI
I needed to do a
chown -R solr:solr for /var/solr/data/drupal
For getting solr to work correctly after enabling the start on boot on a debain server.
Auto boot startes solr as solr user
At installation and configuration it was the root user.
I found a great tutorial on
I found a great tutorial on how to start it automatically on Windows
https://www.norconex.com/how-to-run-solr5-as-a-service-on-windows/
Unable to achieve last step "Making Solr start automatically"
this step by step installing guide went right until last step "Making Solr start automatically"
executing "bin/install_solr_service.sh" returned "ERROR: Must specify the path to the Solr installation archive, such as solr-5.0.0.tgz" and also listed a help page with all the supported options.
When I gave it the archive path which was "/tmp/solr-5.5.1.tgz", it then complaint about "ERROR: /opt/solr already exists! Please move this directory / link or choose a different service name using the -s option."
I don't understand : the "install_solr_service.sh" script is supposed to "make Solr start automatically" not to "reinstall solr", unless I specify that with an option.
solr 5.5.x
also edit solrcore.properties in /var/solr/data/COLLECTIONNAME/conf and fix the path in solr.contrib.dir, to /opt/solr/contrib (for default install)
In my case setup is like
In my case setup is like "solr.contrib.dir=../../../contrib" and this path is correct since solrcore.properties is located at /opt/solr/server/solr/MYCOLLECTIONNAME/conf. There is nothing related to solr under /var. So this didn't help to resolve my start automatically problem. Are you sure that the pats you mention are 5.5.x ?
Yes, should install with data
Yes, should install with data in /var/solr. Is your OS supported? This is what they support from the text at the top of the page:
Symlink patch requires src version
It is important to know, the patch can only be applied when using the source code version of Solr (src).
Installing Solr 5.4 via homebrew
FYI I've created a Homebrew recipe for Solr 5.4, we'll see if it gets merged: https://github.com/Homebrew/homebrew-versions/pull/1366
--
Damien McKenna | Mediacurrent
Easy solution for OSX
It's now possible to install Solr 5.4.1 on OSX using Homebrew, just use the "solr54" formula, e.g.:
It won't work if another version of Solr was already installed via Homebrew, but this will get it installed properly.
Once installed it'll be necessary to copy the Search API Solr config files to
/usr/local/Cellar/solr54/5.4.1/server/solr
and proceed as normal from there.(ps my PR as merged)
--
Damien McKenna | Mediacurrent
Error upon executing bin\solar.cmd start
I've followed the directions as listed above, but then get an error that reads:
"ERROR: The system was unable to find the specified registry key or value.
ERROR: The system was unable to find the specified registry key or value.
Please set the JAVA_HOME environment variable to the path where you installed Java 1.7+"
Do I need to do anything in particular to get the included Java web server installed?
And I intend to use this with Acquia Dev Desktop, does anyone know if there would be an issue with that? I'm a beginner. I'm working on Windows.
This might fix it ...
Go to Control Panel and run the System applet, go to Advanced system settings, then Environment Variables. Look for JAVA_HOME under System variables. If it's not there then add it with the path to your Java install (something like C:\Program Files\Java\jdk1.7xx). You might need a reboot for it to work.
Solr versions 5.5 and higher are incompatible?
if Solr versions 5.5 and higher are incompatible with Search API Solr module in D7, a) it would be nice to see that note further up the page, and b) you might hint where to find Solr downloads lower than 5.5 - http://archive.apache.org/dist/lucene/solr/