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 LTSCreate a new non-root user account with sudo access and switch to it.
adduser johndoe --gecos "John Doe"
usermod -aG sudo johndoe
su - johndoeNOTE: Replace johndoe with your username.
Set up the timezone.
sudo dpkg-reconfigure tzdataEnsure that your system is up to date.
sudo apt update && sudo apt upgrade -yInstall build-essential and libpng-dev.
sudo apt install -y build-essential libpng-devInstall 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-intlCheck 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 TechnologiesInstall MySQL and setup a database
Install MySQL.
sudo apt install -y mysql-serverCheck the version.
mysql --version
# mysql Ver 14.14 Distrib 5.7.22, for Linux (x86_64) using EditLine wrapperRun the mysql_secure installation script to improve MySQL security and set the password for the MySQL root user.
sudo mysql_secure_installationConnect to the MySQL shell as the root user.
sudo mysql -u root -p
# Enter passwordCreate 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 nginxCheck 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 -tReload Nginx.
sudo systemctl reload nginx.serviceInstall Node.js and NPM
Install Node.js.
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt install -y nodejsCheck the Node.js and npm versions.
node -v && npm -v
# v10.2.1
# 5.6.0Install 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/composerCheck the version.
composer --version
# Composer version 1.6.5 2018-05-04 11:44:59Install and configure Monica
Create an empty document root folder where Monica should be installed.
sudo mkdir -p /var/www/monicaNavigate to the document root folder.
cd /var/www/monicaChange ownership of /var/www/monica folder to user johndoe.
sudo chown -R johndoe:johndoe /var/www/monicaClone the Monica repository to it.
git clone https://github.com/monicahq/monica.git .
git checkout tags/v2.1.1NOTE: 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 .envUpdate 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-reqsInstall all the front-end dependencies and tools needed to compile assets.
npm install yarn
npm installCompile the JS and CSS assets.
npm run productionGenerate an application key. This will set APP_KEY to the correct value automatically.
php artisan key:generateRun the migrations and seed the database and symlink folders.
php artisan setup:productionChange ownership of the /var/www/monica directory to www-data.
sudo chown -R www-data:www-data /var/www/monicaPossible 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.