How to Install Monica CRM on Ubuntu with Nginx
This article describes how to install the Monica Personal CRM application on Ubuntu. Monica is an open-source tool designed to help you organize your relationships. You can track birthdays, events, notes, and interactions with friends and family. For more on the project, visit the official website GitHub page.
Note: This guide is for Ubuntu 24.04 and later. While this tutorial covers a manual installation, the industry standard for deploying Monica CRM is now through Docker. Using Docker simplifies updates and dependency management. You can find official Docker deployment documentation on their website.
Why use Monica? It acts as a private memory bank for your social life. What happens when done? You will have a self-hosted web portal where you can securely manage your personal contacts.

Install Nginx
Monica is a web application that needs a server to run. Nginx is a fast and reliable choice. Run these commands to install it:
sudo apt update sudo apt install nginx
For more help with Nginx, see this guide How to install Nginx on Ubuntu Linux.
Install MariaDB
Monica stores your data in a database. MariaDB is the recommended choice. Install it with this command:
sudo apt update sudo apt install mariadb-server
Find additional database help here How to install MariaDB on Ubuntu Linux.
Install PHP-FPM
Monica requires PHP to function. We will use the latest stable version (PHP 8.3) from the PPA maintained by Ondřej Surý.
sudo add-apt-repository ppa:ondrej/php sudo apt update sudo apt install php8.3-fpm php8.3-cli php8.3-common php8.3-mbstring php8.3-xml php8.3-mysql php8.3-curl php8.3-zip php8.3-intl php8.3-bcmath php8.3-gd php8.3-gmp php8.3-redis
For more help with PHP, see this link How to install PHP or PHP-FPM on Ubuntu Linux.
Install Composer
Composer manages the PHP code libraries Monica needs. Use the official installer script to ensure security and proper path management:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
sudo php composer-setup.php --install-dir=/usr/bin --filename=composer
php -r "unlink('composer-setup.php');"Install Node.js and Yarn
These tools handle the visual parts of the Monica interface. We use the current LTS version (v22+).
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash - sudo apt install -y nodejs sudo corepack enable sudo corepack prepare yarn@stable --activate
Create Monica Database
You need to create a specific space for Monica in your database. Log in to the database system:
sudo mysql -u root -p
Run these commands to set up the database and user:
CREATE DATABASE monicadb; CREATE USER 'monicadbuser'@'localhost'; ALTER USER 'monicadbuser'@'localhost' IDENTIFIED BY 'your_strong_password'; GRANT ALL ON monicadb.* TO 'monicadbuser'@'localhost'; FLUSH PRIVILEGES; exit
Install Monica
Download the latest version of Monica from GitHub and configure it. Follow the official project documentation to clone the repository into /var/www/monica. Copy the .env.example file to .env and update the database credentials with the password you created earlier.
Install the required dependencies using Composer and Yarn:
sudo -u www-data composer install --no-interaction --no-dev sudo -u www-data yarn install sudo -u www-data yarn run production
Finish the setup by generating the application key and running the database migrations:
sudo -u www-data php artisan key:generate sudo -u www-data php artisan setup:production -v
Configure Nginx
Create a server block file in /etc/nginx/sites-available/monicacrm. Ensure the fastcgi_pass directive points to the correct PHP socket version:
fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
Enable the site, test the configuration, and restart Nginx to apply the changes.
Access Monica Portal
Navigate to your domain in your web browser. You can now register your account and begin using your CRM. For security, we recommend setting up SSL using Let’s Encrypt How to install and use Let’s Encrypt SSL with Nginx on Ubuntu Linux.
[signed-by=/usr/share/keyrings/yarnkey.gpg]
Was this guide helpful?
Leave a Reply