Installing Solr 6.x
This page details how to set up Apache Solr version 6.x for use with the Search API Solr Search module. As of v7.x-1.12, Solr 6.x releases are supported.
Basic setup
As a pre-requisite for running your own Solr server, you'll need Java Runtime version 8 or higher.
Download the latest version of Solr and unpack the archive somewhere outside of your web server's document tree.
Solr 6.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.
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. If you are root make sure you are sudoing to solr like this: sudo -u solr bin/solr create -c drupal).
Config files
Before configuring the Solr module in drupal you will have to make sure it uses the proper configuration files. These are located in the solr-conf/6.x directory in this module. Copy all the files there to the instance dir of the core you created (you can see this in the "Core Admin" screen), this is usually at /var/solr/data/drupal/ ("drupal" in this case is the core name) and copy all configuration files to the conf folder. Example: cp /var/www/sites/all/modules/contrib/search_api_solr/solr-conf/6.x/*.* /var/solr/data/drupal/conf/. Then, from the "Core Admin" screen, hit the reload button for the core you created.
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
Warnings and notes
Note:
Themapping-ISOLatin1Accent.txtfile 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 anIPAccessHandlertoserver/etc/jetty.xmlas 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.1might 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.1rather thenlocalhost.
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion