Learn How To Install Monica on Fedora 28

January 14, 2020

Table of Contents

If you are using a different system, please check our other tutorials.

Monica is an open source personal relationship management system. Think of it as a CRM (a popular tool used by sales teams in the corporate world) for your friends or family. Its source code is publicly hosted on GitHub. In this guide, we will go over the installation process of a Monica application.


  • Git
  • NPM (Node Package Manager)
  • PHP 7.1 or newer
  • MariaDB
  • Nginx
  • Composer

Check the Fedora version.

cat /etc/fedora-release
# Fedora release 28 (Twenty Eight)

Create a new non-root user account with sudo access and switch to it.

useradd -c "John Doe" johndoe && passwd johndoe
usermod -aG wheel johndoe
su - johndoe

NOTE: Replace johndoe with your username.

Set up the timezone.

timedatectl list-timezones
sudo timedatectl set-timezone 'Region/City'

Ensure that your system is up to date.

sudo dnf check-upgrade || sudo dnf upgrade -y

Install required packages.

sudo dnf install -y git vim wget curl gcc-c++ make libpng12 libpng12-devel

For simplicity, disable SELinux and Firewall.

sudo setenforce 0
sudo systemctl stop firewalld
sudo systemctl disable firewalld

Install PHP

Install PHP and required PHP extensions.

sudo dnf install -y php-cli php-fpm php-common php-mbstring php-xml php-mysqlnd php-curl php-zip php-intl php-json

Check the version.

php --version
# PHP 7.2.7 (cli) (built: Jun 19 2018 14:40:10) ( NTS )

Start and enable PHP-FPM.

sudo systemctl start php-fpm.service
sudo systemctl enable php-fpm.service

Install MariaDB and setup database

Install MariaDB database server.

sudo dnf install -y mariadb-server

Check the version.

mysql --version
# mysql  Ver 15.1 Distrib 10.2.16-MariaDB, for Linux (x86_64) using readline 5.1

Start and enable MariaDB.

sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

Run the mysql_secure_installation script to improve the security of your MariaDB installation.

sudo mysql_secure_installation

Log in to MariaDB as the root user.

mysql -u root -p
# Enter password:

Create a new MariaDB database and user, and remember the credentials.

GRANT ALL ON dbname.* TO 'username' IDENTIFIED BY 'password';

Install and configure Nginx

Install Nginx.

sudo dnf install -y nginx

Check the version.

sudo nginx -v
# nginx version: nginx/1.12.1

Start and enable Nginx.

sudo systemctl start nginx.service
sudo systemctl enable nginx.service

Run sudo vim /etc/nginx/conf.d/monica.conf and configure Nginx for Monica.

server {
  listen 80;
  listen [::]:80;
  server_name example.com;
  root /var/www/monica/public/;
  index index.php;
  charset utf-8;
  location ^~ /storage {
    deny all;  
  location / {
    try_files $uri $uri/ /index.php?$query_string;
  location ~* .php$ {
    fastcgi_split_path_info ^(.+.php)(/.+)$;
    include fastcgi_params;
    fastcgi_pass unix:/run/php-fpm/www.sock;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_buffer_size 16k;
    fastcgi_buffers 4 16k;

Save the file and exit.

Test the configuration.

sudo nginx -t

Reload Nginx.

sudo systemctl reload nginx.service

Install Node.js and NPM

Install Node.js.

curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -
sudo dnf -y install nodejs

Check the Node.js and NPM versions.

node -v && npm -v
# v8.11.3
# 5.6.0

Install Composer

Install Composer.

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '93b54496392c062774670ac18b134c3b3a95e5a5e5c8f1a9f115f203b75bf9a129d5daa8ba6a13e2cc8a1da0806388a8') { 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 version.

composer --version
# Composer version 1.8.0 2018-05-04 11:44:59

Install and configure Monica

Create an empty document root folder where Monica will 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.

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

Clone the Monica repository to it.

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

NOTE: Find the latest official version on the releases page on GitHub and update the above version number to the latest release.

Create your own file containing the environment variables required by Monica.

cp .env.example .env

Update the .env file to your specific needs.

sudo vim .env

Note: Don’t forget to set DB_USERNAME and DB_PASSWORD with the settings used previously.

Install all packages.

composer install --no-interaction --no-suggest --no-dev --ignore-platform-reqs

Install all the front-end dependencies and tools needed to compile assets.

npm install

Compile the JS and CSS assets.

npm run production

Generate an application key. This will set APP_KEY in the .env file to the correct value automatically.

php artisan key:generate

Run the migrations and seed the database and symlink folders.

php artisan setup:production

Change ownership of the /var/www/monica directory to nginx.

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

Run sudo vim /etc/php-fpm.d/www.conf and set user and group to nginx. Initially, it will be set to user and group apache.

sudo vim /etc/php-fpm.d/www.conf
# user = nginx
# group = nginx

Restart php-fpm.service.

sudo systemctl restart php-fpm.service

The installation is complete. Open your domain in your web browser and follow the instructions shown on screen.

Need help?

Do you need help setting up this on your own service?
Please contact us and we’ll provide you the best possible quote!