Docs cipi.yml Web panel API MCP Guides Compare GitHub Telegram channel
  1. Home
  2. Guides
  3. Laravel Scout with Meilisearch, self-hosted
Laravel

Laravel Scout with Meilisearch, self-hosted

Add fast, typo-tolerant search to a Laravel app with Scout and a Meilisearch instance on your own server, isolated per app, with no Algolia bill.

By Updated 2 min read

Here you'll add instant, typo-tolerant product search to a Laravel shop with Scout and Meilisearch, running on the same server. Each app gets a key that can only touch its own indexes.

Meilisearch
$ cipi search install
$ cipi search enable shop

Key ideas, in plain words#

TermMeaning
ScoutLaravel's search layer: Product::search('shoes')->get()
MeilisearchAn open-source search engine, typo-tolerant and fast
IndexMeilisearch's copy of the searchable fields of your models
Filterable / sortable attributesFields you can filter or sort on; they must be declared

1. Install Meilisearch on the server#

bash
sudo cipi search install

A single binary under systemd, listening on localhost, with a hardened unit and a health check. The master key lives in a root-only file.

2. Prepare the model#

bash
composer require laravel/scout meilisearch/meilisearch-php http-interop/http-factory-guzzle
php artisan vendor:publish --provider="Laravel\Scout\ScoutServiceProvider"
php
use Laravel\Scout\Searchable;

class Product extends Model
{
    use Searchable;

    public function toSearchableArray(): array
    {
        return [
            'id' => $this->id,
            'name' => $this->name,
            'brand' => $this->brand,
            'price' => $this->price,
        ];
    }
}

Filterable and sortable attributes go in config/scout.php under meilisearch.index-settings. Commit and deploy.

3. Enable search for the app#

bash
sudo cipi search enable shop
sudo cipi app artisan shop scout:sync-index-settings
sudo cipi app artisan shop scout:import "App\Models\Product"

Cipi writes SCOUT_DRIVER=meilisearch, the host, a key scoped to shop-* indexes and the prefix into the app's .env.

Step 1 of 3App shop

Cipi writes SCOUT_PREFIX=shop- to the app's .env, so its indexes are named shop-products, shop-users…

php
$results = Product::search($request->q)
    ->where('brand', 'Acme')
    ->paginate(20);

Add scout:sync-index-settings to your deploy steps so settings follow the code:

yaml
# cipi.yml
search: true
deploy:
  post:
    - artisan scout:sync-index-settings

Operations#

TaskCommand
Status and keyssudo cipi search status --check, sudo cipi search list
Rotate the app keysudo cipi search key rotate shop (.env updated)
Upgradesudo cipi search upgrade (old binary returns if the store is refused)
Turn off for an appsudo cipi search disable shop --purge-indexes

Troubleshooting#

ProblemFix
No resultsNot imported yet: scout:import "App\Models\Product"
Attribute is not filterableDeclare it in scout.meilisearch.index-settings, then scout:sync-index-settings
Changes don't show upSCOUT_QUEUE=true and no worker running, or searchable() not called
invalid_api_keyKey rotated: check MEILISEARCH_KEY in .env, cipi search status --check

Questions

Is Meilisearch exposed to the internet?

No. It listens on 127.0.0.1 only, and each app gets a key limited to its own indexes.

How much memory does it need?

Cipi refuses to install below 512 MB available and warns below 1 GB. Plan RAM for your index size.

Small catalogue?

Scout's database driver or PostgreSQL full-text search need no extra service.

Does each app get its own Meilisearch?

Apps share one Meilisearch service, but each gets its own key restricted to its own index prefix, so one app can't read another's indexes.

How much RAM does Meilisearch need?

It memory-maps the index: plan roughly the size of your indexed data plus headroom. Small catalogues fit in a few hundred MB.

Do I re-import after every deploy?

No. Scout keeps indexes in sync on save. Re-import only after changing toSearchableArray() or index settings.

What if a step fails?

Read the troubleshooting table above first. Then check the matching docs page, open a GitHub issue, or ask in the community. Most commands print the fix when they refuse something.

Try it on your own server

Free and open source. One command on a fresh Ubuntu 24.04 or 26.04 VPS.

wget -O - https://cipi.sh/setup.sh | bash
Read the quickstart