Meilisearch Cloud is the recommended way to run Meilisearch in production environments.
Prerequisites
- An AWS account
- An EC2 instance running Ubuntu 22.04 LTS or Amazon Linux 2023
- An SSH key pair to connect to that instance
- A security group allowing inbound traffic on ports 22 (SSH), 80 (HTTP), and 443 (HTTPS)
Step 1: Install Meilisearch
Log into your EC2 instance via SSH and update the system packages:- Ubuntu
- Amazon Linux
curl to download and run the Meilisearch command-line installer:
/usr/local/bin to make it accessible from anywhere:
Step 2: Create system user
Running applications as root exposes you to unnecessary security risks. Create a dedicated user for Meilisearch:Step 3: Create a configuration file
Create the directories where Meilisearch will store its data:/etc/meilisearch.toml and update the following lines, replacing MASTER_KEY with a secure 16-byte string:
Step 4: Run Meilisearch as a service
Create a systemd service file to run Meilisearch as a background service:Step 5: Secure and finish your setup
5.1. Configure security groups
Ensure your EC2 security group allows:- Port 22 for SSH access
- Port 80 for HTTP traffic
- Port 443 for HTTPS traffic
5.2. Set up a reverse proxy with Nginx
Install Nginx:- Ubuntu
- Amazon Linux
your_domain with your actual domain name (or use _ as a catch-all if you don’t have one yet).
Enable and restart Nginx:
5.3. Enable HTTPS with Let’s Encrypt
Before enabling HTTPS, ensure you have a domain name pointing to your EC2 instance’s public IP address.
- Ubuntu
- Amazon Linux
Conclusion
Your Meilisearch instance is now running on AWS EC2 with:- A dedicated system user for security
- Automatic restart via systemd
- Nginx reverse proxy
- HTTPS encryption via Let’s Encrypt