在homestead 的homestead.yml 配置文件中添加php
features: - elasticsearch: version: 7
開啓homestead 中的 elasticsearch css
由於須要安裝軟件因此須要設置國內的鏡像laravel
打開 homestead/scripts/features/elasticssearch.sh文件git
將apt-get 安裝的內容替換爲github
sed -i "s@http://.*archive.ubuntu.com@http://mirrors.huaweicloud.com@g" /etc/apt/sources.list sed -i "s@http://.*security.ubuntu.com@http://mirrors.huaweicloud.com@g" /etc/apt/sources.list sudo apt-get update wget https://mirrors.huaweicloud.com/elasticsearch/7.6.1/elasticsearch-7.6.1-amd64.deb sudo apt-get -y install openjdk-11-jre # sudo apt-get -y install elasticsearch"$installVersion" sudo dpkg -i elasticsearch-7.6.1-amd64.deb # Start Elasticsearch on boot sudo update-rc.d elasticsearch defaults 95 10
設置國內的鏡像shell
在 /etc/elasticsearch/elasticsearch.yml 中添加ubuntu
network.host: 0.0.0.0 discovery.seed_hosts: ["127.0.0.1", "::1"]
重啓elasticsearchcomposer
sudo service elasticsearch restart
打開 /usr/share/elasticsearch/pluginselasticsearch
建立 文件夾工具
sudo mkdir ik
將下載的 https://github.com/medcl/elas... 解壓到 ik文件夾中
unzip xxx.zip
重啓服務
sudo service elasticsearch restart
kibana 是一款界面管理工具 官方出品的
composer require tamayo/laravel-scout-elastic composer require laravel/scout //版本可能不兼容 具體看composer中的兼容版本 php artisan vendor:publish //選擇其中的配置文件發佈
發佈配置文件後須要對配置文件進行更改
'driver' => env('SCOUT_DRIVER', 'algolia'), //在env 中 添加 elasticsearch
在 scount.php 中添加
'elasticsearch' => [ 'index' => env('ELASTICSEARCH_INDEX', 'products'), 'hosts' => [ env('ELASTICSEARCH_HOST', 'http://localhost'), ] ]
具體的配置看我的的配置進行
到如今基本上算是配置完成了 詳細使用說明可看