There is a new version of this tutorial available for Debian 11 (Bullseye).

How to Install Monica Personal Relationship Manager on Debian 10

Monica is an open source Personal Relationship Management (PRM) web application designed to organize interactions with your loved ones. Think of it as a CRM (a popular tool used by sales teams in the corporate world) for your friends or family. Monica allows people to keep track of everything important about their friends and family. Like the activities done with them. When you last called someone. What you talked about. It will help you remember the name and the age of the kids. It can also remind you to call someone you haven't talked to in a while.

Features

  • Add and manage contacts
  • Define relationships between contacts
  • Reminders
  • Auto reminders for birthdays
  • Stay in touch with contact by sending reminders at a given interval
  • Management of debts
  • Ability to add notes to a contact
  • Ability to indicate how you've met someone
  • Management of activities done with a contact
  • Management of tasks
  • Management of gifts
  • Management of addresses and all the different ways to contact someone
  • Management of contact field types
  • Management of contact pets
  • Basic journal
  • Ability to indicate how the day went
  • Upload documents and photos
  • Export and import of data
  • Export contact as vCard
  • Ability to set custom genders
  • Ability to define custom activity types
  • Ability to favorite contacts
  • Track conversations made on social media or SMS
  • Multi-users
  • Labels to organize contacts
  • Ability to define what section should appear on the contact sheet
  • Multi currencies
  • Multi-languages
  • An API that covers most of the data

Requirements

  • Debian 10.x (Buster)
  • Git
  • NPM (Node Package Manager)
  • PHP version 7.1 or newer
  • MySQL
  • HTTP server with PHP support (eg: Apache, Nginx, Caddy...)
  • Composer
  • Optional: Redis or Beanstalk

Prerequisites

  • A Debian 10 (buster) operating system.
  • A non-root user with sudo privileges.

Initial steps

Check your Debian version:

lsb_release -ds
# Debian GNU/Linux 10 (buster)

Set up the timezone:

sudo dpkg-reconfigure tzdata

Update your operating system packages (software). That is an essential first step because it ensures you have the latest updates and security fixes for your operating system's default software packages:

sudo apt update && sudo apt upgrade -y

Install some essential packages that are necessary for basic administration of the Debian operating system:

sudo apt install -y curl wget vim git unzip socat bash-completion apt-transport-https libpng-dev

Step 1 - Install PHP

Install PHP, as well as the required PHP extensions:

sudo apt install -y php php-cli php-fpm php-common php-mbstring php-xml php-mysql php-curl php-zip php-intl php-bcmath php-gd php-json php-gmp

To show PHP compiled in modules, you can run:

php -m

ctype
curl
exif
fileinfo
. . .
. . .

Check the PHP version:

php --version

# PHP 7.3.11-1~deb10u1 (cli) (built: Oct 26 2019 14:14:18) ( NTS )
# Copyright (c) 1997-2018 The PHP Group
# Zend Engine v3.3.11, Copyright (c) 1998-2018 Zend Technologies
# with Zend OPcache v7.3.11-1~deb10u1, Copyright (c) 1999-2018, by Zend Technologies

PHP-FPM service is automatically started and enabled on reboot on the Debian 10 system, so there is no need to start and enable it manually. We can move on to the next step.

Step 2 - Install acme.sh client and obtain Let's Encrypt certificate ( optional )

Securing your site with HTTPS is not necessary, but it is a good practice to secure your site traffic. To obtain a TLS certificate from Let's Encrypt we will use acme.sh client. Acme.sh is a simple UNIX shell software for obtaining TLS certificates from Let's Encrypt with zero dependencies.

Download and install acme.sh:

sudo su - root
git clone https://github.com/Neilpang/acme.sh.git
cd acme.sh
./acme.sh --install --accountemail [email protected]
source ~/.bashrc
cd ~

Check acme.sh version:

acme.sh --version
# v2.8.2

Obtain RSA and ECC/ECDSA certificates for your domain/hostname:

# RSA 2048
acme.sh --issue --standalone -d example.com --keylength 2048
# ECDSA
acme.sh --issue --standalone -d example.com --keylength ec-256

If you want fake certificates for testing, you can add --staging flag to the above commands.

After running the above commands, your certificates and keys will be in:

  • For RSA: /home/username/example.com directory.
  • For ECC/ECDSA: /home/username/example.com_ecc directory.

To list your issued certs you can run:

acme.sh --list

Create a directory to store your certs. We will use the /etc/letsencrypt directory.

mkdir -p /etc/letsecnrypt/example.com
sudo mkdir -p /etc/letsencrypt/example.com_ecc

Install/copy certificates to /etc/letsencrypt directory.

# RSA
acme.sh --install-cert -d example.com --cert-file /etc/letsencrypt/example.com/cert.pem --key-file /etc/letsencrypt/example.com/private.key --fullchain-file /etc/letsencrypt/example.com/fullchain.pem --reloadcmd "sudo systemctl reload nginx.service"
# ECC/ECDSA
acme.sh --install-cert -d example.com --ecc --cert-file /etc/letsencrypt/example.com_ecc/cert.pem --key-file /etc/letsencrypt/example.com_ecc/private.key --fullchain-file /etc/letsencrypt/example.com_ecc/fullchain.pem --reloadcmd "sudo systemctl reload nginx.service"

All the certificates will be automatically renewed every 60 days.

After obtaining certs exit from root user and return to regular sudo user:

exit

Step 3 - Install MariaDB and create a database for Monica

Install MariaDB database server:

sudo apt install -y mariadb-server

Check the MariaDB version:

mysql --version
# mysql  Ver 15.1 Distrib 10.3.17-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

Run mysql_secure installation script to improve MariaDB security and set the password for MariaDB root user:

sudo mysql_secure_installation

Answer each of the questions:

Would you like to setup VALIDATE PASSWORD plugin? N
New password: your_secure_password
Re-enter new password: your_secure_password
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

Connect to MariaDB shell as the root user:

sudo mysql -u root -p
# Enter password

Create an empty MariaDB database and user for Monica and remember the credentials:

mariadb> CREATE DATABASE dbname;
mariadb> GRANT ALL ON dbname.* TO 'username' IDENTIFIED BY 'password';
mariadb> FLUSH PRIVILEGES;

Exit from MariaDB:

mariadb> exit

Replace dbname, username and password with your names.

Step 4 - Install and configure NGINX

Monica will work fine with most major web server software with PHP support, but in this guide, we will use NGINX. Feel free to use Apache if you prefer it over NGINX.

Install NGINX:

sudo apt install -y nginx

Check the NGINX version:

sudo nginx -v
# nginx version: nginx/1.14.2

Run sudo vim /etc/nginx/sites-available/monica.conf command and configure NGINX for Monica.

server {
    listen 80;
    listen [::]:80;
    listen 443 ssl;
listen [::]:443 ssl;

ssl_certificate /etc/letsencrypt/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/example.com/private.key;
ssl_certificate /etc/letsencrypt/example.com_ecc/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/example.com_ecc/private.key;
server_name example.com; root /var/www/monica/public; index index.php; location / { try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.3-fpm.sock; } }

Activate new monica.conf configuration by linking the file to the sites-enabled directory:

sudo ln -s /etc/nginx/sites-available/monica.conf /etc/nginx/sites-enabled/

Test NGINX configuration:

sudo nginx -t

Reload NGINX:

sudo systemctl reload nginx.service

Step 5 - Install Node.js and npm

Install Node.js:

curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt install -y nodejs

Check Node.js and npm versions:

node -v && npm -v
# v12.13.0
# 6.12.0

Step 6 - Install Composer

Install Composer:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'a5c698ffe4b8e849a443b120cd5ba38043260d5c4023dbf93e1558871f1f07f58274fc6f4c93bcfd858c6bd0775cd8d1') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
sudo mv composer.phar /usr/local/bin/composer

Check the Composer version:

composer --version
# Composer version 1.9.1 2019-11-01 17:20:17

Step 7 - Install and configure Monica

Create an empty document root folder where Monica should be installed:

sudo mkdir -p /var/www/monica

Navigate to the document root folder:

cd /var/www/monica

Change ownership of /var/www/monica folder to user johndoe:

Don't forget to replace "johndoe" with your username.

sudo chown -R johndoe:johndoe /var/www/monica

Clone Monica repository to it:

git clone https://github.com/monicahq/monica.git .
git checkout tags/v2.15.2

NOTE: Check out to a tagged version of Monica since the master branch may not always be stable. Find the latest official version on the releases page on Github and update it to the above version number to the latest release.

To create your version of all the environment variables needed for the project to work run:

cp .env.example .env

Update .env to your specific needs. Don't forget to set DB_USERNAME and DB_PASSWORD with the settings used behind. You'll need to configure a mail server for registration and reminders to work correctly.

Run composer install --no-interaction --no-suggest --no-dev to install all packages.

Run php artisan key:generate to generate an application key. This will set APP_KEY with the right value automatically.

Run php artisan setup:production -v to run the migrations, seed the database and symlink folders.

Set the appropriate ownership and permissions:

sudo chown -R www-data:www-data /var/www/monica
sudo chmod -R 775 /var/www/monica/storage

Step 8 - Complete the Monica installation

Now, open your web browser and type the URL http://example.com. You will be redirected to the following page:

Create an account

Provide your email address, name, and password. Then, click on the Register button. You should see the Monica dashboard in the following page:

Monica PRM login

Share this page:

0 Comment(s)