Monica is a free, open source web-based Personal Relationship Management software written in the Laravel framework. It is used to keep track of all the important details about your friends and family. You can easily add and manage contacts, define relationships between contacts, set auto reminders for birthdays using Monica. You can also track conversations made on social media or SMS using Monica. Monica has an ability to define what section should appear on the contact sheet.

 

In this tutorial, we will learn how to install Monica PRM on Ubuntu 18.04 server.

 

Requirements

  • A server running Ubuntu 18.04.
  • A root password is set up on your server.

 

Getting Started

 

First, you will need to update your system with the latest version. You can do it with the following command:

apt-get update -y
apt-get upgrade -y

 

Once your system is updated, restart the system to apply these changes.

 

Install Nginx, MariaDB and PHP

 

First, you will need to install Nginx, MariaDB server, PHP and other PHP modules to your server. You can install all of them by running the following command:

apt-get install nginx mariadb-server 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 git wget unzip -y

 

Once all the packages are installed, you can proceed to the Next step.

 

Configure MariaDB

 

By default, MariaDB installation is not secured, so you will need to secure it first. You can secure it with the following command:

 

mysql_secure_installation

 

    Enter current password for root (enter for none):
    Set root password? [Y/n]: N
    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

 

Once MariaDB is secured, log in to MariaDB shell with the following command:

mysql -u root -p

 

Enter your root password. Then, create a database and user for Monica with the following command:

MariaDB [(none)]> create database monica;
MariaDB [(none)]> create user monica@localhost identified by 'password';

 

Next, grant all the privileges to the Monica with the following command:

MariaDB [(none)]> GRANT ALL ON monica.* TO 'monica'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;

 

Next, flush the privileges and exit from the MariaDB shell with the following command:

MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

 

Install Composer and Node.j

 

Next, you will need to install Composer to your system. The composer is a package manager for the PHP programming language. It is used to install all the required dependencies by PHP.

 

First, download the composer installer with the following command:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

 

Next, you will need to verify the data integrity of the script by comparing the script SHA-384 hash with the latest installer hash found on the Composer Public Key page. You can do it with the following command:

HASH="$(wget -q -O - https://composer.github.io/installer.sig)"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

 

If everything will be fine, you should see the following output:

Installer verified

 

Next, install Composer with the following command:

php composer-setup.php --install-dir=/usr/local/bin --filename=composer

 

You should see the following output:

All settings correct for using Composer
Downloading...

Composer (version 1.8.4) successfully installed to: /usr/local/bin/composer
Use it: php /usr/local/bin/composer

 

Next, install Node.js with the following command:

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

 

Install and configure Monica

 

Next, you will need to create a directory structure for Monica. You can do this with the following command:

mkdir -p /var/www/monica

 

Next, change the directory to monica and download the latest version of Monica with the following command:

cd /var/www/monica
git clone https://github.com/monicahq/monica.git .
git checkout tags/v2.1.1

 

You should see the following output:

Note: checking out 'tags/v2.1.1'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b 

HEAD is now at dcfd15fa Update translations (#1324)

 

Next, you will need to rename the example environment variable file. You can do it with the following command:

mv .env.example .env

 

Next, open .env file and define your database and username:

nano .env

 

Make the following changes:

# Database information
# To keep this information secure, we urge you to change the default password
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
# You can use mysql unix socket if available, it overrides DB_HOST and DB_PORT values.
#DB_UNIX_SOCKET=/var/run/mysqld/mysqld.sock
DB_DATABASE=monica
DB_USERNAME=monica   
DB_PASSWORD=password

 

Next, install all the required PHP dependencies using Composer with the following command:

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

 

Next, install all front-end dependencies with the following command:

npm install

 

Next, compile the JS and CSS with the following command:

npm run production

 

Next, generate an application key with the following command:

php artisan key:generate

 

Next, migrate and seed the database with the following command:

php artisan setup:production

 

You should see the following output:

 You are about to setup and configure Monica. Do you wish to continue? (yes/no) [no]:

 You are about to setup and configure Monica. Do you wish to continue? (yes/no) [no]:
 > yes

 
-----------------------------
|
| Welcome to Monica v2.1.1
|
-----------------------------
| You can now register to the first account by opening the application:
| URL:      http://localhost
-----------------------------
Setup is done. Have fun.

 

Next, provide proper permissions to the monica directory with the following command:

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

 

Once you have done, you can proceed to the next step.

 

Configure Nginx for Monica

 

Next, you will need to create an Nginx virtual host file for Monica. You can do this by creating monica.conf file in/etc/nginx/sites-available/ directory with the following command:

nano /etc/nginx/sites-available/monica.conf

 

Add the following lines:

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 and close the file. Then, restart Nginx service with the following command:

systemctl restart nginx

 

You can now check the status of Nginx with the following command:

systemctl status nginx

 

Output:

? nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2019-02-15 10:03:53 UTC; 2min 12s ago
     Docs: man:nginx(8)
  Process: 22598 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=killed, signal=TERM)
  Process: 22612 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
  Process: 22601 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
 Main PID: 22613 (nginx)
    Tasks: 2 (limit: 1114)
   CGroup: /system.slice/nginx.service
           ??22613 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
           ??22615 nginx: worker process

Feb 15 10:03:53 ubuntu1804 systemd[1]: nginx.service: Failed with result 'timeout'.
Feb 15 10:03:53 ubuntu1804 systemd[1]: Stopped A high performance web server and a reverse proxy server.
Feb 15 10:03:53 ubuntu1804 systemd[1]: Starting A high performance web server and a reverse proxy server...
Feb 15 10:03:53 ubuntu1804 systemd[1]: nginx.service: Failed to parse PID from file /run/nginx.pid: Invalid argument
Feb 15 10:03:53 ubuntu1804 systemd[1]: Started A high performance web server and a reverse proxy server.

 

Access Monica

 

Monica is now installed and configured. It's time to access the Monica web interface. Now, open your web browser and type the URL http://example.com. You will be redirected to the page.  Provide your email address, name, and password. Then, click on the Register button. You should see the Monica dashboard.

 

Congratulations! you have successfully installed Monica on Ubuntu 18.04 server. You can now easily manage your contacts using Monica from a central location. If you want then our experts can do this for you.

 

Was this answer helpful? 0 Users Found This Useful (0 Votes)