How to Install Typesense on a DigitalOcean Droplet with Ubuntu LTS

December 30, 2024
When your website or application needs a fast and highly customizable search engine, Typesense can be a great option. In this article, I’ll explain how to create a Droplet on DigitalOcean and set up Typesense on an Ubuntu LTS environment quickly and easily.
1. Why Use DigitalOcean and Ubuntu LTS?
DigitalOcean offers an intuitive control panel and reliable infrastructure for deploying virtual servers (Droplets). Meanwhile, Ubuntu LTS (Long Term Support) guarantees security updates and stability for five years, making it ideal for production environments.
2. Creating a Droplet on DigitalOcean
-
Sign In
- Access your DigitalOcean account.
-
Create a New Droplet
- In the dashboard, click Create > Droplets.
- Choose the Ubuntu LTS image (e.g., 22.04 or the latest available LTS).
- Pick a plan with at least 2 GB of RAM for optimal performance.
-
Configure Access and Firewall
- Add your SSH key for passwordless connections.
- Give your Droplet a name, such as
typesense-droplet. - In Networking > Firewalls, make sure to open port 22 (SSH) and, if needed, ports 80 (HTTP) and 443 (HTTPS).
- If you plan to make Typesense accessible over the internet, allow port 8108 (or the one you’ll use in your setup).
-
Create the Droplet
- Click Create Droplet and wait a few minutes for the process to complete.
3. Installing Typesense on Ubuntu
-
SSH into the Droplet
From your local terminal, connect to the Droplet:ssh root@<YOUR_DROPLET_IP>(Replace
rootwith another username if applicable.) -
Update the System
Once you’re logged in, run:sudo apt update && sudo apt upgrade -yThis ensures you have the latest patches and updates.
-
Download the Typesense Package
Visit the official Typesense page to find the available version. For instance, if the version is 27.1, download the.debpackage:curl -O https://dl.typesense.org/releases/27.1/typesense-server-27.1-amd64.deb -
Install the Package
Usedpkgto install:sudo dpkg -i typesense-server-27.1-amd64.debIf you encounter missing dependencies, fix them with:
sudo apt-get install -f -
Verify the Installation
Check the binary path:which typesense-serverIt should show something like
/usr/bin/typesense-server. -
Configure Typesense
- Create (or edit) the config file at
/etc/typesense/typesense-server.ini:[server] api-key = YOUR_SECURE_API_KEY listen-port = 8108 data-dir = /var/lib/typesense - Replace
YOUR_SECURE_API_KEYwith a secure key of your choice. - Adjust the port if you prefer something other than 8108.
- Create (or edit) the config file at
-
Prepare the Data Directory
sudo mkdir -p /var/lib/typesense sudo chown -R root:root /var/lib/typesenseMake sure the user running Typesense has the proper read/write access.
-
Start the Service
Check if thetypesense-serverservice was created:systemctl status typesense-serverIf it shows active (running), you’re all set. Otherwise:
sudo systemctl start typesense-server sudo systemctl enable typesense-serverThis ensures that Typesense automatically starts on server reboot.
-
Configure the Firewall
- If you want the server to accept external connections on 8108, you need to open that port in DigitalOcean’s firewall.
- If you use
ufwon the Droplet, run:sudo ufw allow 8108/tcp sudo ufw reload
4. Testing the Setup
To verify that Typesense is running, use:
curl http://localhost:8108/health
You should see a JSON response indicating that Typesense is operational.
Conclusion
That’s it! By following these steps, you’ve installed Typesense on a DigitalOcean Droplet running Ubuntu LTS. You now have a search engine infrastructure ready for indexing, scalability, and customization. Feel free to tweak your queries, fine-tune relevancy, and get the most out of Typesense.
I hope this guide has been helpful. If you have any questions or want to share your experience, drop a comment below! Happy searching!