In this post I will cover how to install and configure Monica personal CRM for ubuntu Linux with Nginx.
As an open source solution for keeping in touch with a lot of people, Monica is a CRM (a Contacts/Relationship Manager). The Web-based interface means it’s simple to organize contacts, especially with people in common.
Monica Personal CRM is a flexible and customizable web application for organizations, individuals and small businesses. It provides an efficient way for you to manage your contacts and various records, allowing you to search data in any format reliably; it also provides integration with external systems that gives you the ability to save data with minimal effort.
For more information about Monica, please visit its GitHub page.
When you are ready, follow the steps below to Installing Monica Personal CRM on Ubuntu Linux system.
How to install Monica personal relation manager on Ubuntu Linux with Nginx
Below is how to install Monica on Ubuntu Linux with Nginx support:
Install Nginx
Monica is an open-source web application written in PHP. It requires a web server, and one of the best servers to use would be Nginx.
Run the commands below to install Nginx web server on Ubuntu Linux:
sudo apt update
sudo apt install nginx
Additional resources for installation of Nginx are available at the link below:
How to Install Nginx on Ubuntu Linux
Install MariaDB
MariaDB is a secure, fast and open-source database server that you can use with Monica to store its content.
To install MariaDB database server, simply run the commands below:
sudo apt update
sudo apt install mariadb-server
Install PHP-FPM
As described above, Monica is an application written in PHP. The most recent version of Monica CRM requires a minimum level of PHP v8.1 or higher for it to function properly.
Run the command below to install PHP on Ubuntu Linux:
sudo apt update
sudo apt install php8.1-fpm php8.1-cli php8.1-common php8.1-mbstring php8.1-xml php8.1-mysql php8.1-curl php8.1-zip php8.1-intl php8.1-bcmath php8.1-gd php8.1-gmp php8.1-redis
Install Composer
PHP Composer is a PHP package management tool that provides PHP dependencies. You might require Composer to install Monica’s dependencies.
To install Composer, run the command below:
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/bin --filename=composer
Install Node.js and Yarn
Node.js and Yarn will be utilized for the download and compilation of static files for Monica CRM.
Simply run the command the below to add the Node.js Node package repository:
curl -fsSL https://deb.nodesource.com/setup_16.x | sudo bash -
Next, add the Yarn package repository by using the command below :
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
Now, we have Node.js and Yarn package repository in our system, so run the command below to install them :
sudo apt update
sudo apt install nodejs yarn
At this point, we have all required packages to install and configure Monica.
Create Monica Database
To create database for Monica, run the commands below to log in to the MariaDB shell :
sudo mysql -u root -p
Next, create a database named monicadb using command below:
CREATE DATABASE monicadb;
Now, run the command below to create a database user named monicadbuser:
CREATE USER monicadbuser@localhost;
Grant all access to the newly created database user to the database and create a new password by using command below:
GRANT ALL ON monicadb.* TO 'monicadbuser'@'localhost' IDENTIFIED BY 'your_type_password_here';
Finally, save your changes and exit:
FLUSH PRIVILEGES;
exit;
Now, we are ready to install Monica.
Install Monica
To install Monica, first we need to clone Monica project from GitHub :
sudo apt install git
cd /var/www/
sudo git clone https://github.com/monicahq/monica.git
Next, Check for the stable branch version i.e. 3.7.0 by running the command below :
cd /var/www/monica
sudo git checkout tags/v3.7.0
After that, run the command below to copy the default configuration .env.example file to .env file inside the Monica directory as show below:
sudo cp /var/www/monica/.env.example /var/www/monica/.env
Next, change the file ownership to ‘www-data‘ by using the command below :
sudo chown www-data:www-data /var/www/monica/.env
To open and edit the .env file, run the command below:
sudo nano /var/www/monica/.env
And then update the highlighted lines in .env file to match your system environment as show below :
# The URL of your application.
APP_ENV=production
APP_URL=http://monica.example.com
# Force using APP_URL as base url of your application.
# You should not need this, unless you are using subdirectory config.
APP_FORCE_URL=false
# Database information
# To keep this information secure, we urge you to change the default password
# Currently only "mysql" compatible servers are working
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=monicadb
DB_USERNAME=monicadbuser
DB_PASSWORD=type_password_here
DB_PREFIX=
DB_TEST_HOST=127.0.0.1
DB_TEST_DATABASE=monica_test
DB_TEST_USERNAME=homestead
DB_TEST_PASSWORD=secret
# Use utf8mb4 database charset format to support emoji characters
next, save the file and exit.
Next, change the directory permissions and create a new folder as show below:
sudo chown -R www-data:www-data /var/www/monica
sudo mkdir -p /var/www/.cache
sudo chown -R www-data:www-data /var/www/.cache
Install PHP dependencies for Monica by using command below :
sudo -u www-data composer install --no-interaction --no-dev
After that, create a new folder for Yarn and change its permissions to work with Nginx web server:
sudo mkdir -p /var/www/.yarn
sudo chown -R www-data:www-data /var/www/.yarn
Next, install and compile Monica dependencies and environment as show below:
sudo -u www-data yarn install
sudo -u www-data yarn run production
sudo -u www-data php artisan key:generate
sudo -u www-data php artisan setup:production -v
During the execution of commands above, it should prompt you if you want to configure Monica? so simply type Yes to continue process:
At the end, you will see the output similar like below:
-----------------------------
|
| Welcome to Monica v3.7.0
| You can now log in to your account
| URL: http://monica.example.com
Setup is done. Have fun.
To ensure that Monica’s app will function smoothly, we need to update its directory permissions to allow the web server have control over what information can be modified.
sudo chown -R www-data:www-data /var/www/monica
sudo chmod -R 775 /var/www/monica/storage
Configure Nginx for Monica
Next, you will need to configure Nginx server to get the Monica portal working properly. To do that, create a server block for Monica by using the command below:
sudo nano /etc/nginx/sites-available/monicacrm
After that, copy and paste the lines below into the file as show below:
server {
listen 80;
server_name monica.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/php8.1-fpm.sock;
}
}
Save and close the file.
Next, enable the server block:
sudo ln -s /etc/nginx/sites-available/monicacrm /etc/nginx/sites-enabled/
Run the command below to test and restart Nginx for check errors:
sudo nginx -t
sudo systemctl restart nginx
After running the command above, If you don’t get any errors, you’re installation process completed successfully.
Access Monitor Portal
At this point, Monica Personal CRM is now installed and configured. To access the Monica web interface open your web browser and type the URL http://monica.example.com :
http://monica.example.com
You can Login and register yourself and start using Monica Application.
That’s all
Conclusion
Congratulations! You have successfully installed Monica Personal CRM on Ubuntu Linux using Nginx, MariaDB and PHP. If you have any questions, feel free to leave a comment below and we will get back to you as soon as possible!
If our tutorials helped you, please consider buying us a coffee. We appreciate your support!
Thank you for your support.