Posts Learn Components Snippets Categories Tags Tools new About

Setting up Meilisearch on Production Ubuntu for Laravel project

Learn how to get up and running MeiliSearch on the production ubuntu server and get your Laravel project search to the next level

9 months ago

7 mins read


In this post, you'll be learning how to host MeiliSearch on the production ubuntu server and integrate it with your Laravel project. You can make use of any VPS platform such as Vultr or Hetzner or DigitalOcean and for this case, we'll be showing you how to set up the one that's ready-created by Laravel Forge.

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".
Once you are in the user directory you can install MeiliSearch using curl and move the binaries to the "/usr/bin" directory.
# Install MeiliSearch
curl -L | sh

# Move MeiliSearch bindary to the system binaries
mv ./meilisearch /usr/bin
By moving the binary into the system binaries now you will be able to run the "meilisearch" command from anywhere.

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
Paste the following script, do note that you will have to change your "YoUrV3ry-S3cur3-aP1k3Y" master key into your own secure defined master key.

ExecStart=/usr/bin/meilisearch --http-addr --env production --master-key YoUrV3ry-S3cur3-aP1k3Y

Once you have pasted it now you can save it by typing :wq which is "write and quit" command in vim.

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
When checking if MeiliSearch is running you will get output as follows.
● 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.

Other Tutorial

By now you should be able to Set up Meilisearch on Production Ubuntu for the Laravel project. If you found this tutorial to be helpful do share it with your friends and cheers.

Alternative Tags

If you like our tutorial, do make sure to support us by being our Patreon or buy us some coffee ☕️