How to Install Monica on Ubuntu 18.04

In this tutorial, we will show you how to install Monica on Ubuntu 18.04 server.

Monica is an open-source personal Customer Relation Management (CRM) software written in PHP, built on top of the Laravel framework. Monica allows you to store information about your family, friends, coworkers, and more. For example, you can store information such as your friend’s wedding anniversary, the names of the children of all of your family members, keep track of your debt, and stay on top of your productive life. Let’s begin with the installation.

This guide should work on other Linux VPS systems as well, but it was tested and written for Ubuntu 18.04 VPSes.

Step 1: Update the System Packages

Log in to your VPS via SSH as root or as a sudo user:

ssh username@IP_Address -p Port_Number

Don’t forget to replace IP_Address and Port_Number with their respective values.

Issue the following commands to update all installed packages:

sudo apt-get update
sudo apt-get upgrade

Step 2: Install Nginx, MySQL and PHP 7

To install Nginx, MySQL, PHP 7 and all the necessary PHP modules on your Ubuntu server, run the following apt command:

sudo apt-get install nginx mysql-server \
    php7.2 php7.2-cli php7.2-common php7.2-json php7.2-opcache \
    php7.2-mysql php7.2-mbstring php7.2-zip php7.2-fpm php7.2-bcmath \
    php7.2-intl php7.2-xml php7.2-curl php7.2-gd

When the MySQL installation is complete, secure your MariaDB installation using the mysql_secure_installationscript:

sudo mysql_secure_installation

Then, answer the security questions as follows. If it asks for a password at any point, just press the [Enter] key, as no password is set by default:

Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y

Step 3: Install Composer

Composer is a dependency manager for PHP with which you can install packages. Composer will pull in all the required libraries and dependencies you need for your project.

curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

Step 4: Create a MySQL Database

Log in to the MariaDB console with the MariaDB root user using the password you have set up in the previous step:

mysql -u root -p

Create a MariaDB database and user for Monica, and grant permissions to the user using the following command:

mysql> CREATE SCHEMA `monica` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
mysql&gt; GRANT ALL PRIVILEGES ON monica.* TO 'monica'@'localhost' IDENTIFIED BY '<span style="color: #ff0000;">strongpassword</span>';
mysql&gt; FLUSH PRIVILEGES;
mysql&gt; \q

Make sure you replace ‘strongpassword‘ with an actual strong password.

Step 5: Install Monica

Installing Monica is pretty easy and straightforward – first, clone the Attendize repository from Github:

cd /var/www/html
git clone https://github.com/monicahq/monica.git

Visit the Monica release page to find the latest stable version. At the time of writing this post, the latest version of Monica is “2.12.1”.

Run the following command to check out the tagged version of Monica:

cd /var/www/html/monica
git checkout tags/v2.12.1

Next, rename the .env.example file to .env using the following command:

sudo mv .env.example .env

Open the .env file and update the database details:

DB_DATABASE=monica
DB_USERNAME=monica
DB_PASSWORD=<span style="color: #ff0000;">strongpassword
</span>

Also, edit the SMTP server details and enter your information.

Install all PHP dependencies with composer:

cd /var/www/html/monica
composer install --no-interaction --no-suggest --no-dev

Once Composer has downloaded the components, run the key:generate command to generate an application key.

php artisan key:generate

Then migrate the database:

php artisan setup:production
You are about to setup and configure Monica. Do you wish to continue? (yes/no) [no]:
 > yes
-----------------------------
|
| Welcome to Monica v2.12.1
|
-----------------------------
| You can now register to the first account by opening the application:
| URL:      http://localhost
-----------------------------
Setup is done. Have fun.

If you want to access the Monica API, create the access tokens like this:

php artisan passport:install 

Change the file ownership to the www-data user with the following command:

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

Step 6: Configure Nginx to Serve the Monica Instance

Open your favorite text editor and create a new Nginx server block for the Monica application:

sudo nano /etc/nginx/sites-available/<span style="color: #ff0000;">your_monica_domain.com</span>.conf
server {
    listen 80 default_server;
    server_name <span style="color: #ff0000;">your_monica_domain.com</span> www.<span style="color: #ff0000;">your_monica_domain.com</span>; 
    root /var/www/html/monica/public; 
    index index.php; 
    charset utf-8; 
    location / { try_files $uri $uri/ /index.php?$query_string; } 
    location = /favicon.ico { access_log off; log_not_found off; } 
    location = /robots.txt { access_log off; log_not_found off; } 
    access_log /var/log/nginx/<span style="color: #ff0000;">your_monica_domain.com</span>.access.log; 
    error_log /var/log/nginx/<span style="color: #ff0000;">your_monica_domain.com</span>.error.log; sendfile off; 
    location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; 
    fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; 
    fastcgi_index index.php; include fastcgi_params; 
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
    fastcgi_intercept_errors off; 
    fastcgi_buffer_size 16k; 
    fastcgi_buffers 4 16k; } 
    location ~ /\.ht { deny all; } 
}

Don’t forget to replace your_monica_domain.com with your actual registered domain name. Activate the server block by creating a symbolic link with the following command:

sudo ln -s /etc/nginx/sites-available/<span style="color: #ff0000;">your_monica_domain.com</span>.conf  /etc/nginx/sites-enabled/<span style="color: #ff0000;">your_monica_domain.com</span>.conf

Test the Nginx configuration to ensure that there are no syntax errors using the following command:

sudo nginx -t

If it all checks out, restart the nginx service:

sudo service nginx restart

Step 7: Create a Monica Admin account

Open http://your_monica_domain.com/ in your preferred web browser – you will then be redirected to the Monica setup page.

Enter your first name, last name, email address, and password. This user is going to be the Monica administrator account.

Finally, select the “Signing up signifies you’ve read and agree to our Privacy Policy and Terms of use.” and click on the Register button to finish the installation.

That’s it. You have successfully installed Monica on Ubuntu 18.04. For more information about how to manage your Monica installation, please refer to the official Monica documentation.


Of course, you don’t have to install Monica on Ubuntu 18.04 if you use one of our Managed Linux Cloud VPS Hosting services, in which case you can simply ask our expert system administrators to install Monica on Ubuntu 18.04 for you using the LEMP stack or any other web hosting stack of your choice. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post on how to install Monica on Ubuntu 18.04, please share it with your friends on the social networks using the share shortcuts, or simply leave a comment in the comments section. Thank you.

1 thought on “How to Install Monica on Ubuntu 18.04”

  1. Great Share! Thanks for sharing this valuable information on How to Install Monica on Ubuntu 18.04 through your informative article. The points you explained here are very detail and It will surely help us further.

    Reply

Leave a Comment