Please consider using ddev/ddev-solr, which runs Solr in the modern "Cloud" mode. This offers several advantages. If you are using Drupal, the biggest advantage
is that you can update the Solr Configset from the UI or with a Drush command everytime you update search_api_solr.
The current addon runs in "classic standalone" mode. It is probably simpler at first to setup, but comes with the added maintainance steps for configsets. Most Solr hosting service providers run "Solr Cloud" as a backend.
Apache Solr is the blazing-fast, open source, multi-modal search platform built on the full-text, vector, and geospatial search capabilities of Apache Lucene™.
This add-on integrates Solr for Drupal 9+ into your DDEV project. It follows the Setting up Solr (single core) - the classic way recipe.
-
ddev add-on get ddev/ddev-drupal-solr ddev restart
- You may need to install the relevant Drupal requirements:
ddev composer require drush/drush drupal/search_api_solr
- Enable the
search_api_solrmodule either using the web interface orddev drush en -y search_api_solr
- Create a Search API server at
admin/config/search/search-api-> "Add server" - Create a server with the following settings
- Set "Server name" to anything you want. Maybe
ddev-solr-server. - Set "Backend" to
Solr - Configure Solr backend
- Set "Solr Connector" to
Standard - Set "Solr host" to
solr - Set "solr core" to
dev - Under "Advanced server configuration" set the "solr.install.dir" to
/opt/solr.
- Set "Solr Connector" to
- Set "Server name" to anything you want. Maybe
ddev restart
If you get a message about Solr having outdated config files, you need to update the included Solr config files.
- Click "Get config.zip" on the server page
- Unzip the files, and put the config files into
.ddev/solr/conf/ - Run
ddev restart
See the documentation in the doc folder
| Command | Description |
|---|---|
ddev launch :8943 |
Open Solr Admin (HTTPS) in your browser (https://<project>.ddev.site:8943) |
ddev launch :8983 |
Open Solr Admin (HTTP) in your browser (http://<project>.ddev.site:8983) |
ddev describe |
View service status and used ports for Solr |
ddev logs -s solr |
Check Solr logs |
This originates from the classic Drupal solr:8 image recipe used for a long time by Drupal users and compatible with search_api_solr.
- It installs a
.ddev/docker-compose.solr.yamlusing thesolr:8docker image. - A standard Drupal 9+ Solr configuration is included in .ddev/solr/conf.
- A .ddev/docker-entrypoint-initdb.d/solr-configupdate.sh is included and mounted into the Solr container so that you can change Solr config in
.ddev/solr/confwith just addev restart.
- The Solr Admin interface will be accessible at:
https://<projectname>.ddev.site:8943/solr/andhttp://<projectname>.ddev.site:8983/solr/. For example, if the project is namedmyprojectthe hostname will be:https://myproject.ddev.site:8943/solr/. - To access the Solr container from inside the web container use:
http://solr:8983/solr/ - A Solr core is automatically created by default with the name "dev"; it can be accessed (from inside the web container) at the URL:
http://solr:8983/solr/devor from the host athttps://<projectname>.ddev.site:8943/solr/#/~cores/dev. You can obviously create other cores to meet your needs.
If you want to use a core name other than the default "dev", add a .ddev/docker-compose.solr-env.yaml with these contents, using the core name you want to use:
services:
solr:
environment:
- SOLR_CORENAME=somecorename- Change
SOLR_CORENAMEenvironment variable in theenvironment:section. - Change your Drupal configuration to use the new core.
You can delete the "dev" core from https://<projectname>.ddev.site:8943/solr/#/~cores/dev by clicking "Unload".
If you would like to use more than one Solr core, add a .ddev/docker-compose.solr_extra.yaml to override some of the default configuration.
-
Define a mount point for each core you require. Add new mount points for each core, for example:
services: solr: volumes: - ./solr:/solr-conf - ./core2:/core2-conf - ./core3:/core3-conf
-
Create the directories for your new cores' config, and copy the desired solr config in to it, eg:
cp -R .ddev/solr .ddev/core2 cp -R .ddev/solr .ddev/core3 cp -R path/to/core2-config/* .ddev/core2/conf/ cp -R path/to/core3-config/* .ddev/core3/conf/
-
Set the
entrypointvalue to useprecreate-coreinstead ofsolr-precreateand add the additional cores, along with a command to start solr afterwards:services: solr: entrypoint: 'bash -c "VERBOSE=yes docker-entrypoint.sh precreate-core solrconf /solr-conf ; precreate-core core2 /core2-conf ; precreate-core core3 /core3-conf ; exec solr -f "'
-
Your finished
.ddev/docker-compose.solr_extra.yamlfile should now look something like this:services: solr: volumes: - ./solr:/solr-conf - ./core2:/core2-conf - ./core3:/core3-conf entrypoint: 'bash -c "VERBOSE=yes docker-entrypoint.sh precreate-core solrconf /solr-conf ; precreate-core core2 /core2-conf ; precreate-core core3 /core3-conf ; exec solr -f "'
-
Finally,
ddev restartto pick up the changes and create the new cores.
- This recipe won't work with versions of Solr before
solr:8, and Acquia's hosting requires Solr 7. You'll want to see the contributed recipes for older versions of Solr.
Contributed by @rfay
Maintained by @mkalkbrenner, @bserem, and the DDEV team