Ga naar inhoud

Installeren met Trellis

Elasticsearch install and configure for development

Install Elasticsearch in Trellis
Check version requirement for ElasticPress plugin

Go to Github ElasticPress and check for EP_ES_VERSION_MAX. At time of writing this is set to 6.2. Make sure you install the latest compatible version of Elasticsearch.

Add requirements to trellis/requirements.yml
...
- name: elastic.elasticsearch
version: 6.2.4
Install new requirements in trellis/ folder
Terminal window
$ ansible-galaxy install -r requirements.yml
Update memory for Vagrant box in trellis/vagrant.default.yml
...
vagrant_memory: 2048 # in MB
...

Note: after this step you need to rebuild your vagrant box for the changes to take effect.

Configure trellis/dev.yml file with variables and role

Add variables for Elasticsearch just below the β€˜remote_user’ line.

...
remote_user: vagrant
vars:
es_enable_xpack: false
es_instance_name: "node1"
es_restart_on_change: true
es_start_service: true
roles:
...

Add Elasticsearch role at the end of the β€˜roles’ section

...
- { role: wordpress-setup, tags: [wordpress, wordpress-setup] }
- { role: wordpress-install, tags: [wordpress, wordpress-install] }
- { role: elastic.elasticsearch, tags: [elasticsearch] }

In the next steps we will apply the changed configuration to the virtual machine.


Backup your vagrant database from the trellis/ folder

Terminal window
vagrant ssh
cd /srv/www/domainname.com/current
wp db export
exit

This creates a sql dump file of the current state.

Rebuild Vagrant box from your trellis/ folder

Terminal window
vagrant destroy
default: Are you sure you want to destroy the 'default' VM? [y/N] y
vagrant up

This may take a while depending on the speed of your machine. (~5-10 minutes)

Import your database

After vagrant is rebuild run this from your trellis/ folder.

Terminal window
vagrant ssh
cd /srv/www/domainname.com/current
wp db import FILENAME.sql

Where FILENAME is the filename of your db backup.

All done!

Configure ElasticPress to connect to Elasticsearch

Install the ElasticPress plugin from the site/ folder
Terminal window
composer require wpackagist-plugin/elasticpress
Activate and configure ElasticPress plugin
  1. Enter http://127.0.0.1:9200 as Elasticsearch Host
  2. Sync with ElasticPress plugin