I'm using drupalvm to create my local dev environment, and am writing scripts to automate importing an existing site's db and changing other settings so that it's more like our actual server-hosted sites.

Drupalvm creates a Solr server at /solr/collection1 and uses HTTP, whereas the existing site looks for a Solr server at /solr/live and uses HTTPS. When the db is imported, the local site is looking in the wrong place for the Solr server.

I'd like to check the feasibility of adding another .sh script that changes the db entry for search_api_server so that it uses http and /solr/collection1.

I tried using a sql command to update/set the new value for search_api_server 'options', and it does successfully change the scheme to HTTP but doesn't change the path. Also, when I load the site's search api server admin page, the options seem to be completely empty at first and you have to edit and save them again for it to stick.

P.s. I am also currently testing changing drupalvm's default Solr server so that it uses /solr/live and https, but having some issues with the https part.


This problem was probably specific to Drupal-VM, but here's how I solved it. Rather than write a post-provision script that tried to run the sql command itself, I made a new file containing the sql command and told the post-provision script to use that file.

So instead of the script running this itself

sudo mysql -u root -proot drupal -e "UPDATE search_api_server SET options = 'a:14:{s:9:"clean_ids";b:1;s:9:"site_hash";b:1;s:6:"scheme";s:4:"http";s:4:"host";s:9:"localhost";s:4:"port";s:4:"8983";s:4:"path";s:17:"/solr/collection1";s:9:"http_user";s:0:"";s:9:"http_pass";s:0:"";s:7:"excerpt";i:0;s:13:"retrieve_data";i:0;s:14:"highlight_data";i:0;s:17:"skip_schema_check";i:0;s:12:"solr_version";s:0:"";s:11:"http_method";s:4:"AUTO";}' WHERE id='1'";

It now does this

sudo mysql -u root -proot drupal < $SEARCH_API_SERVER_SETUP_SQL_COMMAND_FILE

(Replace -u root -proot drupal with your sql username, password, and the site db)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.