How to Self-Host Monica on a VPS (Complete Guide)
Self-hosting applications is an exciting way to regain control over your data and customize functionality to fit your needs. Monica is an open-source personal CRM (customer relationship management) tool that helps you manage personal relationships. By self-hosting Monica on a VPS (Virtual Private Server), you can ensure that your data remains private and secure.
In this guide, weโll cover how to install Monica on a VPS using Docker, along with tips for configuration and maintenance.
Prerequisites
-
VPS Provider: Choose a reliable VPS provider. Hereโs a comparison of some popular options:
Provider Price per Month RAM Storage Contabo VPS 5.99 EUR 4GB 1TB SSD Hetzner Cloud 4.15 EUR 2GB 20GB SSD DigitalOcean 6 USD 1GB 25GB SSD Vultr 6 USD 1GB 25GB SSD Linode (Akamai) 5 USD 1GB 25GB SSD You can find a suitable VPS for your needs at selfhostvps.com/en/best/.
-
Docker Installed: Ensure Docker is installed on your VPS. If youโre unfamiliar with Docker, it is a platform for developing, shipping, and running applications in containers.
-
Domain Name (Optional): If you want to access Monica through a friendly URL, consider setting up a domain name to point to your VPS.
Step 1: Connect to Your VPS
Use SSH to connect to your server. Open your terminal and run:
ssh root@your_vps_ip
Replace your_vps_ip with the actual IP address of your VPS. If youโre using a service like Hetzner or Contabo, youโll find the IP address in your account dashboard.
Step 2: Install Docker
Docker can be installed with a single command for most Linux distributions. For Ubuntu, run:
sudo apt update
sudo apt install docker.io -y
sudo systemctl start docker
sudo systemctl enable docker
Verify the installation by running:
docker --version
Step 3: Install Docker Compose
Docker Compose is useful for managing multi-container Docker applications. To install Docker Compose, run:
sudo apt install docker-compose -y
Confirm the installation:
docker-compose --version
Step 4: Set Up Monica
Create a new directory for Monica:
mkdir monica && cd monica
Create a docker-compose.yml file with the following content:
version: '3.7'
services:
app:
image: monicahq/monica
restart: always
ports:
- "8080:80"
environment:
- APP_URL=http://your_vps_ip:8080
- DB_CONNECTION=mysql
- DB_HOST=db
- DB_PORT=3306
- DB_DATABASE=monica
- DB_USERNAME=monica
- DB_PASSWORD=secret
depends_on:
- db
db:
image: mysql:5.7
restart: always
environment:
- MYSQL_ROOT_PASSWORD=rootpassword
- MYSQL_DATABASE=monica
- MYSQL_USER=monica
- MYSQL_PASSWORD=secret
volumes:
- db_data:/var/lib/mysql
volumes:
db_data:
Replace your_vps_ip with your actual VPS IP. Adjust other settings such as passwords and environment variables as necessary.
Step 5: Launch Monica
In the directory where your docker-compose.yml file is located, run:
docker-compose up -d
This command starts the Monica application and its database in detached mode.
Step 6: Access Monica
After a few moments, Monica should be up and running. Open your browser and navigate to:
http://your_vps_ip:8080
Complete the setup by creating an admin account and configuring your preferences.
FAQs
What are the advantages of self-hosting Monica?
Self-hosting Monica provides full control over your data, allowing you to customize your experience based on personal needs. You can also enhance privacy by not relying on third-party services. Additionally, thereโs the potential for cost savings compared to subscription-based services, especially if you are already using a VPS.
Can I use HTTPS with Monica?
Yes, it is highly recommended to secure your installation with HTTPS. You can achieve this by using a reverse proxy such as Nginx or Traefik with Letโs Encrypt for SSL certificates. By doing so, communication between your clients and the VPS will be encrypted, providing an additional layer of security.
What if I encounter issues during installation?
If you face any issues while self-hosting Monica, consider checking the official Monica GitHub repository for troubleshooting tips or seek help from the community on platforms like r/selfhosted or the awesome-selfhosted list. Common issues may involve Docker configuration, firewall settings, or database connections.
By following these steps, you will have successfully self-hosted Monica on a VPS. The community is vast, and leveraging resources from forums and repositories can help ease your self-hosting journey.