Knowledgebase

How to Install Monica on Ubuntu 18.04 LTS Print

  • 0

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.

Requirements

  • Ubuntu Server 18.04 LTS (Bionic Beaver)
  • Git
  • NPM (Node Package Manager)
  • PHP 7.1+ or newer
  • MySQL
  • Nginx
  • Composer

Note about Git: Git will most likely be already installed on the Ubuntu server. In case it's not, you can easily install it by running: sudo apt install -y git

Check the Ubuntu version.

lsb_release -ds
# Ubuntu 18.04 LTS

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

adduser johndoe --gecos "John Doe"
usermod -aG sudo johndoe
su - johndoe

NOTE: Replace johndoe with your username.

Set up the timezone.

sudo dpkg-reconfigure tzdata

Ensure that your system is up to date.

sudo apt update && sudo apt upgrade -y

Install build-essential and libpng-dev.

sudo apt install -y build-essential libpng-dev

Install PHP

Install PHP 7.2 and required PHP extensions.

sudo apt install -y php7.2 php7.2-cli php7.2-fpm php7.2-common php7.2-mbstring php7.2-xml php7.2-mysql php7.2-curl php7.2-zip php7.2-intl

Check the version.

php --version

# PHP 7.2.5-0ubuntu0.18.04.1 (cli) (built: May  9 2018 17:21:02) ( NTS )
# Copyright (c) 1997-2018 The PHP Group
# Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
#     with Zend OPcache v7.2.5-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies

Install MySQL and setup a database

Install MySQL.

sudo apt install -y mysql-server

Check the version.

mysql --version
# mysql  Ver 14.14 Distrib 5.7.22, for Linux (x86_64) using  EditLine wrapper

Run the mysql_secure installation script to improve MySQL security and set the password for the MySQL root user.

sudo mysql_secure_installation

Connect to the MySQL shell as the root user.

sudo mysql -u root -p
# Enter password

Create an empty MySQL database and user for Monica, and remember the credentials.

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

Install and configure Nginx

Install Nginx.

sudo apt install -y nginx

Check the version.

sudo nginx -v
# nginx version: nginx/1.14.0 (Ubuntu)

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

server {
    listen 80;
    listen [::]:80;
    
    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.2-fpm.sock;
    }
}

Save the file and exit.

Activate the 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 the configuration.

sudo nginx -t

Reload Nginx.

sudo systemctl reload nginx.service

Install Node.js and NPM

Install Node.js.

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

Check the Node.js and npm versions.

node -v && npm -v
# v10.2.1
# 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') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { 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.6.5 2018-05-04 11:44:59

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.

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.1.1

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

Run the following to create your own version of the environment variables needed for the project.

cp .env.example .env

Update the .env file to your specific needs. 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 yarn
npm install

Compile the JS and CSS assets.

npm run production

Generate an application key. This will set APP_KEY 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 www-data.

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

Possible issue: The NPM package vue-directive-tooltip has had it's directory structure changed, but monicahq config hasn't changed it yet (as of 09/2019). To fix that, the following line in /var/www/monica/resources/assets/js/app.js needs to be changed from:

import 'vue-directive-tooltip/css/index.css'
to
import 'vue-directive-tooltip/src/css/index.css'

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

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. Requirements Ubuntu Server 18.04 LTS (Bionic Beaver) Git NPM (Node Package Manager) PHP 7.1+ or newer MySQL Nginx Composer Note about Git: Git will most likely be already installed on the Ubuntu server. In case it's not, you can easily install it by running: sudo apt install -y git Check the Ubuntu version. lsb_release -ds # Ubuntu 18.04 LTS Create a new non-root user account with sudo access and switch to it. adduser johndoe --gecos "John Doe" usermod -aG sudo johndoe su - johndoe NOTE: Replace johndoe with your username. Set up the timezone. sudo dpkg-reconfigure tzdata Ensure that your system is up to date. sudo apt update && sudo apt upgrade -y Install build-essential and libpng-dev. sudo apt install -y build-essential libpng-dev Install PHP Install PHP 7.2 and required PHP extensions. sudo apt install -y php7.2 php7.2-cli php7.2-fpm php7.2-common php7.2-mbstring php7.2-xml php7.2-mysql php7.2-curl php7.2-zip php7.2-intl Check the version. php --version # PHP 7.2.5-0ubuntu0.18.04.1 (cli) (built: May 9 2018 17:21:02) ( NTS ) # Copyright (c) 1997-2018 The PHP Group # Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies # with Zend OPcache v7.2.5-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies Install MySQL and setup a database Install MySQL. sudo apt install -y mysql-server Check the version. mysql --version # mysql Ver 14.14 Distrib 5.7.22, for Linux (x86_64) using EditLine wrapper Run the mysql_secure installation script to improve MySQL security and set the password for the MySQL root user. sudo mysql_secure_installation Connect to the MySQL shell as the root user. sudo mysql -u root -p # Enter password Create an empty MySQL database and user for Monica, and remember the credentials. CREATE DATABASE dbname; GRANT ALL ON dbname.* TO 'username' IDENTIFIED BY 'password'; FLUSH PRIVILEGES; EXIT; Install and configure Nginx Install Nginx. sudo apt install -y nginx Check the version. sudo nginx -v # nginx version: nginx/1.14.0 (Ubuntu) Run sudo vim /etc/nginx/sites-available/monica.conf and configure Nginx for Monica. server { listen 80; listen [::]:80; 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.2-fpm.sock; } } Save the file and exit. Activate the 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 the configuration. sudo nginx -t Reload Nginx. sudo systemctl reload nginx.service Install Node.js and NPM Install Node.js. curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - sudo apt install -y nodejs Check the Node.js and npm versions. node -v && npm -v # v10.2.1 # 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') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { 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.6.5 2018-05-04 11:44:59 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. 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.1.1 NOTE: Find the latest official version on the releases page on GitHub and update the version number above to the latest release. Run the following to create your own version of the environment variables needed for the project. cp .env.example .env Update the .env file to your specific needs. 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 yarn npm install Compile the JS and CSS assets. npm run production Generate an application key. This will set APP_KEY 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 www-data. sudo chown -R www-data:www-data /var/www/monica Possible issue: The NPM package vue-directive-tooltip has had it's directory structure changed, but monicahq config hasn't changed it yet (as of 09/2019). To fix that, the following line in /var/www/monica/resources/assets/js/app.js needs to be changed from: import 'vue-directive-tooltip/css/index.css' to import 'vue-directive-tooltip/src/css/index.css' The installation is complete. Open your domain in your web browser and follow the instructions shown on screen.

Was this answer helpful?
Back

Powered by WHMCompleteSolution