Learn how to install Meilisearch on Ubuntu 24.04 with persistent storage, secure API key, Nginx reverse proxy, and free SSL using Let’s Encrypt.
If we’re building a web app or platform that needs fast, accurate search, then we’ve likely come across tools like Elasticsearch or Algolia. But when it comes to self-hosted, lightning-fast, and developer-friendly search solutions, Meilisearch stands out — especially in 2025.
We’ll walk through how to install Meilisearch on Ubuntu 24.04, configure it for production use, and understand how it works under the hood. Whether we’re running a blog, SaaS platform, or e-commerce store, this guide will help us set up Meilisearch in a way that’s reliable, scalable, and blazing fast.
What is Meilisearch?
Meilisearch is an open-source, RESTful search engine written in Rust. It's designed to deliver instant, typo-tolerant, and full-text search capabilities out of the box. Think of it as the open-source alternative to Algolia, but with full control — no rate limits, no API cost tiers.
Some standout features:
- Full-text search with typo-tolerance
- High performance (thanks to Rust)
- RESTful API
- Easy setup with minimal dependencies
- Supports filters, synonyms, ranking rules
- Open-source and self-hosted
Prerequisites
Before we begin, let’s ensure we have the following in place:
- A Ubuntu 24.04 dedicated server or KVM VPS.
- A basic programming knowledge.
- A domain name pointing to server IP.
How to Install Meilisearch on Ubuntu 24.04 with Nginx SSL – Step-by-Step Self-Hosted Search Engine Guide [2025]
Step 1: Update the Ubuntu System
We begin by updating our system to ensure we’re working with the latest security patches and libraries.
sudo apt update && sudo apt upgrade -y
This ensures that our system is clean and ready for any new installations.
Step 2: Install Required Dependencies
Meilisearch doesn’t require a heavy stack, but we’ll need curl and unzip to handle the binary download:
sudo apt install curl unzip -y
These tools help us download and extract the latest Meilisearch release from the official GitHub repository.
Step 3: Download the Latest Meilisearch Binary
Head over to the official GitHub release page to find the latest stable version:
We’ll download the latest Linux x86_64 build using the command below:
curl -L https://install.meilisearch.com | sh
This script downloads the binary, makes it executable, and places it in our working directory.
To move it to a global location:
sudo mv meilisearch /usr/local/bin/
Step 4: Start Meilisearch for the First Time
Now that it’s installed, we can launch Meilisearch with a simple command:
meilisearch
By default, it runs on port 7700 with no authentication. Let’s verify that it’s working by opening:
http://localhost:7700
We should see a JSON welcome message from Meilisearch's API.
Step 5: Configure Meilisearch with Environment Variables
For production environments, we’ll want to enable an API key, change the host/port, and persist data.
Let’s create a directory for storing Meilisearch data:
sudo mkdir -p /var/lib/meilisearch
sudo chown $USER /var/lib/meilisearch
Now, we can start Meilisearch with persistent storage and security:
MEILI_MASTER_KEY="mySuperSecretKey" \
MEILI_ENV="production" \
MEILI_DB_PATH="/var/lib/meilisearch" \
meilisearch
Replace "mySuperSecretKey
" with a secure API key.
To make this permanent, we’ll set up a systemd service next.
Step 6: Create a Systemd Service (Auto-Start on Boot)
Let’s make sure Meilisearch starts on system boot and runs in the background:
sudo nano /etc/systemd/system/meilisearch.service
Paste the following config:
[Unit]
Description=Meilisearch
After=network.target
[Service]
User=ubuntu
ExecStart=/usr/local/bin/meilisearch \
--env production \
--db-path /var/lib/meilisearch \
--master-key mySuperSecretKey
Restart=always
[Install]
WantedBy=multi-user.target
Replace ubuntu
with the actual username of the machine. Save and exit.
Enable and start the service:
sudo systemctl daemon-reexec
sudo systemctl enable meilisearch
sudo systemctl start meilisearch
Now Meilisearch is running as a background service, even after reboots.
Step 7: Interact with the Meilisearch API
We can now use tools like curl, Postman, or our frontend/backend to interact with Meilisearch.
Example: Add an Index and Documents
curl \
-X POST 'http://localhost:7700/indexes/movies/documents' \
-H 'Authorization: Bearer mySuperSecretKey' \
-H 'Content-Type: application/json' \
--data-binary '[
{ "id": 1, "title": "Inception", "genre": "Sci-Fi" },
{ "id": 2, "title": "Avengers", "genre": "Action" }
]'
Example: Perform a Search
curl \
-X POST 'http://localhost:7700/indexes/movies/search' \
-H 'Authorization: Bearer mySuperSecretKey' \
-H 'Content-Type: application/json' \
--data-binary '{ "q": "incep" }'
Notice how Meilisearch returns "Inception" even with a typo — that’s its smart ranking system at work.
Step 8: Secure Meilisearch (Firewall + API Key)
If our server is exposed to the internet, we must secure the instance:
Use strong API keys – never use "masterKey" in production.
Use UFW firewall:
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw reload
Step 9: Proxy Meilisearch Through Nginx with SSL (HTTPS)
To secure our Meilisearch API with HTTPS and optionally expose it to the public internet, we’ll place Nginx in front of it and use Let’s Encrypt SSL.
This step assumes we already have a domain (e.g., search.yourdomain.com
) pointed to the server’s IP.
1. Install Nginx
sudo apt install nginx -y
Start and enable the service:
sudo systemctl start nginx
sudo systemctl enable nginx
2. Configure Nginx Reverse Proxy
Create a new configuration file:
sudo nano /etc/nginx/sites-available/meilisearch
Paste the following:
server {
listen 80;
server_name search.yourdomain.com;
location / {
proxy_pass http://localhost:7700;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Enable the site and restart Nginx:
sudo ln -s /etc/nginx/sites-available/meilisearch /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
Now, visiting http://search.yourdomain.com will proxy traffic to Meilisearch running on port 7700.
3. Secure with SSL Using Let’s Encrypt
Install Certbot:
sudo apt install certbot python3-certbot-nginx -y
Obtain and apply the certificate:
sudo certbot --nginx -d search.yourdomain.com
When prompted, choose the option to redirect HTTP to HTTPS.
Certbot will:
- Generate a free SSL certificate
- Automatically update our Nginx config
- Enable HTTPS redirection
Step 9: Add Meilisearch to Our Application
We can take previous search example and use domain name instead of http://localhost:7700
curl \
-X POST 'https://pok.hnxcode.dev/indexes/movies/search' \
-H 'Authorization: Bearer mySuperSecretKey' \
-H 'Content-Type: application/json' \
--data-binary '{ "q": "incep" }'
Meilisearch works with most programming languages using HTTP requests. Official and community SDKs exist for:
- Node.js
- Python
- PHP
- Go
- Ruby
- Java
Example (Node.js with meilisearch package):
npm install meilisearch
Code:
import { MeiliSearch } from 'meilisearch'
const client = new MeiliSearch({
host: 'https://search.yourdomain.com',
apiKey: 'mySuperSecretKey'
})
const index = client.index('movies')
const results = await index.search('Avengers')
console.log(results)
Final Thoughts
By setting up Meilisearch on Ubuntu 24.04, we’ve equipped our project with a modern, powerful search engine that puts speed, typo-tolerance, and relevance first. It's lightweight, flexible, and designed with developers in mind.
Whether we’re building a personal blog, e-commerce platform, or a SaaS product, Meilisearch helps our users find results faster and smarter.
If we liked this guide, consider exploring advanced topics like:
Custom ranking rules
Synonym configuration
Real-time indexing
Multi-language support