Running Magento 2.4.0 on Valet+

Valet Plus+, Magento 2

As just about everyone i wanted to play with Magento 2.4.0 as it came out. Just do a composer create-project, wait some time, and run bin/magento install, right? Noooope. Magento will fail with an ElasticSearch error. No problem, Valet+ supports ElasticSearch, so just install it. You check the wiki, Valet+ supports ElasticSearch 6.8. Hmm, Magento requires version 7.6. There is an open PR, but no official release. Are there any other solutions?

Docker to the rescue

You can install ElasticSearch directly onto your system but that might bite other projects you have running. Luckily for us, it is quite easy to get ElasticSearch up and running. First of all, make sure you don't have any existing ElasticSearch instances running:

brew services stop elasticsearch

You can check if it is stopped by opening http://localhost:9200 in your browser, you shouldn't get a response.

Next, add this docker-compose.yml file to your project:

version: '2.2'
        container_name: elasticsearch
            - bootstrap.memory_lock=true
            - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
            - cluster.initial_master_nodes=node-1
                soft: -1
                hard: -1
            - esdata:/usr/share/elasticsearch/data
            - "9200:9200"
            - esnet
        container_name: kibana
            - ./kibana.yml:/usr/share/kibana/config/kibana.yml
            - "5601:5601"
            - esnet
        driver: local

Then start the containers by running this command:

docker-compose up -d

Downloading and starting the container takes a moment, but it also takes a few minutes for ElasticSearch to start up, so give it some time. When everything is started you can check if it is working again by opening http://localhost:9200 in your browser again. You should get a response similar to this:

name: "node-1",
cluster_name: "docker-cluster",
cluster_uuid: "zuOL47PLSRqM3WzUHEyREg",
version: {
    number: "7.6.2",
    build_flavor: "default",
    build_type: "docker",
    build_hash: "ef48eb35cf30adf4db14086e8aabd07ef6fb113f",
    build_date: "2020-03-26T06:34:37.794943Z",
    build_snapshot: false,
    lucene_version: "8.4.0",
    minimum_wire_compatibility_version: "6.8.0",
    minimum_index_compatibility_version: "6.0.0-beta1"
tagline: "You Know, for Search"
} (ad)

Do you want your Magento store to be more reliable? Tired of things that suddenly break the checkout process without anyone noticing? You can hire my services to kickstart End-2-End testing for your Magento store. This way you know for sure that your store is behaving as expected before releasing that new feature or that update.

View for more information.


Next to ElasticSearch this docker-compose.yml also adds Kibana, a tool that can be used to discover the contents of your ElasticSearch installation. You can view it by navigating to http://localhost:5601. If Kibana asks for an index pattern, enter magento2_product*. After going through the installation wizard you can view your database contents by clicking the Discover tab.

Want to respond?