Getting typesense right from the start saves hours of debugging later. In this comprehensive guide, we'll cover everything from initial setup to production-ready configuration, including search and static considerations.
Prerequisites
- A registered domain name (for public-facing services)
- A database server (MySQL/PostgreSQL)
- A VPS running Ubuntu 22.04 or later (2GB+ RAM recommended)
- Root or sudo access to the server
- A web server with PHP (if applicable)
Installation Guide
For production deployments, consider implementing high availability by running multiple instances behind a load balancer. This approach provides both redundancy and improved performance under heavy load.
# Install dependencies for CMS
sudo apt update
sudo apt install -y nginx mysql-server php-fpm php-mysql php-xml php-mbstring php-curl php-gd
# Download and install
cd /var/www
sudo wget https://example.com/typesense-latest.tar.gz
sudo tar xzf typesense-latest.tar.gz
sudo chown -R www-data:www-data /var/www/typesense
Note that file paths may vary depending on your Linux distribution. The examples here are for Debian/Ubuntu; adjust paths accordingly for RHEL/CentOS-based systems.
Advanced Settings
If you encounter issues during setup, check the system logs first. Most problems can be diagnosed by examining the output of journalctl or the application-specific log files in /var/log/.
Database Configuration
After applying these changes, monitor the server's resource usage for at least 24 hours to ensure stability. Tools like htop, iostat, and vmstat can provide real-time insights into system performance.
# Create database for the CMS
sudo mysql -e "CREATE DATABASE typesense_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
sudo mysql -e "CREATE USER 'typesense'@'localhost' IDENTIFIED BY 'secure_password';"
sudo mysql -e "GRANT ALL PRIVILEGES ON typesense_db.* TO 'typesense'@'localhost';"
sudo mysql -e "FLUSH PRIVILEGES;"
The configuration above sets the recommended values for a VPS with 2-4GB of RAM. Adjust the memory-related settings proportionally if your server has different specifications.
Wrapping Up
Following this guide, your typesense setup should be production-ready. Keep an eye on resource usage as your traffic grows and don't forget to test your backup and recovery procedures periodically.