Step 1: SSH into the server and Install MeiliSearch
The first step is to SSH into the server and installs MeiliSearch with curl. Do note that you need to install this within the user directory which is "forge".
# Install MeiliSearch curl -L https://install.meilisearch.com | sh # Move MeiliSearch bindary to the system binaries mv ./meilisearch /usr/bin
Step 2: Run MeiliSearch as a Service
The next step is to run MeiliSearch as a service that will always be running in the background. By making it a service, it will automatically be launched when the system reboot and etc.
To add the service, create a new "meilisearch.service" using vim as follows.
sudo vim /etc/systemd/system/meilisearch.service
[Unit] Description=MeiliSearch After=systemd-user-sessions.service [Service] Type=simple ExecStart=/usr/bin/meilisearch --http-addr 127.0.0.1:7700 --env production --master-key YoUrV3ry-S3cur3-aP1k3Y [Install] WantedBy=default.target
Step 3: Enable and Start the Service
Once it's ready now you can enable and start the service by running the command below. Do note that you might need to input your sudo password.
# Enable meilisearch service systemctl enable meilisearch # Start the meilisearch service systemctl start meilisearch # Check that the service is actually running systemctl status meilisearch
● meilisearch.service - MeiliSearch Loaded: loaded (/etc/systemd/system/meilisearch.service; enabled; vendor preset: enabled) Active: active (running) since Wed 2021-08-11 07:49:49 +08; 10s ago Main PID: 3486507 (meilisearch)
Step 4: Connect With Laravel
Now that you have MeiliSearch running in the background, you can update the Laravel environment (.env) file to specify MeiliSearch as the SCOUT driver.
SCOUT_DRIVER=meilisearch SCOUT_QUEUE=true MEILISEARCH_HOST=http://127.0.0.1:7700 MEILISEARCH_KEY=YOUR_MEILISEARCH_KEY
- How to Deploy MeiliSearch on Laravel Forge
- Make Your Laravel Search Smartarter With Laravel Scout and MeiliSearch