What is MeiliSearch?
MeiliSearch, it's the "Next-generation search API" which is just like Algolia but it's open-source and free to use. By default, MeiliSearch is blazing fast, tolerant to typos, synonymous, comes with filterings, language support, and more.
What is Laravel Forge?
Forge allows you to painlessly create and manage PHP servers which include MySQL, Redis, Memcached, database backups, and everything else you need to run robust, modern Laravel applications.
Laravel Forge Server Types
At the time of this writing, Laravel Forge support 7 types of server and below you can see the full breakdown of what is offered by each server type. To run MeiliSearch, they have a dedicated "MeiliSearch Server" and everything that's necessary to run and operate MeiliSearch is managed automatically by Laravel Forge, so you don't have to worry about future updates and more.

Do note that by default you will need to have a server connected to Laravel Forge which you can do so by adding the server by pressing any of the providers below. In this case, Vultr and Hetzner are ready to add a new server.

Step 1: Create Server
Once you have set up a provider create a new server and add the credentials as follows. Make sure to save the sudo password and meilisearch password somewhere safe.

Do note that the server will take about 10 minutes to provision. Grab your coffee in the mean time ☕️

The site will be called "default" and you don't have to change the name, if you do then you can change the name from the "meta" tab within the "default" site.

Step 2: Retrieve the API Keys from the MeiliSearch Sidebar
To retrieve the Public and Private Key you can access it by providing the "Master Password" from the "API Keys" page below.

Pressing "Reveal" will show you the "private" and "public" key like below.

Step 3: Update the Server Network (MeiliSearch-Server)
To allow your MeiliSearch server to connect to other Laravel Forge servers, you have to tick "Can Connect To" from the Network tab.

Step 4: Update the Server Network (Laravel App Server)
The next part is to update the Server Network for your Laravel App Server by ticking the "Can Connect To".

Step 5: Update Laravel Forge Site Environment
Once the connection is made you will have to update the .env configuration from Laravel Forge.
SCOUT_DRIVER=meilisearch SCOUT_QUEUE=true MEILISEARCH_HOST=http://127.0.0.1:7700 MEILISEARCH_KEY=YOUR_MEILISEARCH_KEY
Step 6: Import Laravel Scout Data
Once you have done that you need to SSH into your Laravel application server then run "scout:import" to import any of your models.
php artisan scout:import "App\Models\Post"
Step 7: Test MeiliSearch
Assuming you follow the other tutorial Make Your Laravel Search Smartarter With Laravel Scout and MeiliSearch then you can test MeiliSearch from the URL by passing the query string for the search terms.
Route::get('/search-post', function () { $query = request()->query('query'); $posts = Post::search($query) ->take(10) ->within('posts') ->get(); return $posts; });

By now you should be able to Deploy MeiliSearch on Laravel Forge and on the next tutorial, you'll be learning to build the front-end for the search result so stay tuned for that. If you found this tutorial do share it with your friends and happy coding. 🎉
Other Related Post
- Make Your Laravel Search Smartarter With Laravel Scout and MeiliSearch
- How to Deploy Laravel 8 to Production with Laravel Forge