Welcome to this comprehensive guide on how to install Monica Personal Relationship Manager (CRM) on Debian 11 server. Monica CRM is a powerful, free, and open-source CRM written in PHP that allows you to track personal events, activities, work information, contacts, journals, notes, and more. With its robust features like contact management, reminders, task management, journaling, and data import/export capabilities, Monica CRM is an excellent tool for organizing and managing your personal and professional relationships.
In this article, we will walk you through the step-by-step process of installing Monica CRM on a Debian 11 server. We will also guide you in setting up and configuring the LEMP Stack (Nginx, MariaDB, PHP-FPM), installing PHP dependencies via Composer, and compiling static assets using Node.js and Yarn.
Prerequisites
Before we begin, make sure you have the following prerequisites:
- A Debian 11 server with a non-root user that has root or administrator privileges.
- If you plan to deploy on production, ensure that you have a domain name pointed to your Debian server’s IP address.
- It is recommended to turn on the Firewall on your Debian server for production environments.
Installing Nginx Web Server
To start the installation process, we will first install the Nginx web server.
sudo apt updatesudo apt install nginx
Once the installation is complete, verify the status of the Nginx service.
sudo systemctl is-enabled nginxsudo systemctl status nginx
If everything is set up correctly, you should see that the Nginx service is enabled and running.
Installing MariaDB Server
Next, we will install the MariaDB server, which is the database management system that Monica CRM supports.
sudo apt install mariadb-server
After the installation, verify the status of the MariaDB service.
sudo systemctl is-enabled mariadbsudo systemctl status mariadb
Ensure that the MariaDB service is enabled and running.
Installing and Configuring PHP-FPM 8.1
Now it’s time to install PHP and configure PHP-FPM 8.1 on your Debian 11 server.
curl -sSL https://packages.sury.org/php/README.txt | sudo bash -xsudo apt install php8.1 php8.1-cli php8.1-fpm 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
After installing PHP 8.1, edit the PHP-FPM configuration file.
sudo nano /etc/php/8.1/fpm/php.ini
In the PHP configuration file, modify the following settings:
date.timezone = Europe/Parismax_execution_time = 130memory_limit = 256Mpost_max_size = 128Mupload_max_filesize = 128M
Save the file and restart the PHP-FPM 8.1 service.
sudo systemctl restart php8.1-fpm
Verify the status of the PHP-FPM 8.1 service.
sudo systemctl is-enabled php8.1-fpmsudo systemctl status php8.1-fpm
Installing Composer
Now, let’s install Composer, a dependency management tool for PHP that will be used to install the required PHP dependencies for Monica CRM.
curl-sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer
Verify the installation by checking the version of Composer.
sudo -u www-data composer -v
Installing Node.js and Yarn
Next, we will install Node.js and Yarn, which are required for compiling static files in Monica CRM.
curl -fsSL https://deb.nodesource.com/setup_16.x | bash -curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/nullecho "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.listsudo apt updatesudo apt install nodejs yarn
Verify the installation by checking the versions of Node.js and Yarn.
node --versionyarn --version
Installing Monica CRM
Now that we have all the necessary components installed, let’s proceed with the installation of Monica CRM.
First, clone the Monica CRM repository from GitHub.
cd /var/wwwgit clone https://github.com/monicahq/monica.git
Move to the Monica CRM directory and checkout the desired version.
cd /var/www/monicagit checkout tags/v3.7.0
Copy the default configuration file and change its ownership.
cp /var/www/monica/.env.example /var/www/monica/.envsudo chown www-data:www-data/var/www/monica/.env
Edit the .env
file and update the following settings:
APP_ENV=productionAPP_URL=https://YOUR_DOMAIN.comDB_CONNECTION=mysqlDB_HOST=127.0.0.1DB_PORT=3306DB_DATABASE=monicacrm_dbDB_USERNAME=monicaDB_PASSWORD=password
Change APP_URL
to your domain name, and update the database details with the values you set during the MariaDB setup.
Change the ownership of the Monica CRM installation directory.
sudo chown -R www-data:www-data /var/www/monica
Install the PHP package dependencies using Composer.
sudo -u www-data composer install --no-interaction --no-dev
Create a directory for storing JavaScript packages’ cache.
sudo mkdir -p /var/www/.yarnsudo chown -R www-data:www-data /var/www/.yarn
Install JavaScript packages and generate static files.
sudo -u www-data yarn installsudo -u www-data yarn run production
Generate the application key and migrate the database.
sudo -u www-data php artisan key:generatesudo -u www-data php artisan setup:production -v
Set up a cron job for background tasks.
crontab -u www-data -e
Add the following line to the cron file:
* * * * * /usr/bin/php /var/www/monica/artisan schedule:run >> /dev/null 2>&1
Change the ownership and permissions of the Monica CRM installation directory.
sudo chown -R www-data:www-data /var/www/monicasudo chmod -R 775 /var/www/monica/storage
Setting up Nginx Server Block
To access Monica CRM through a web browser, we need to set up an Nginx server block.
Create a new Nginx configuration file.
sudo nano /etc/nginx/sites-available/monicacrm
Add the following Nginx configuration to the file:
server {listen 80;server_name YOUR_DOMAIN.com;return 301 https://$host$request_uri;}server {listen 443 ssl http2;ssl_certificate /etc/letsencrypt/live/YOUR_DOMAIN.com/fullchain.pem;ssl_certificate_key /etc/letsencrypt/live/YOUR_DOMAIN.com/private.key;server_name YOUR_DOMAIN.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;}}
Replace YOUR_DOMAIN.com
with your actual domain name and ensure that you have valid SSL certificates.
Activate the Nginx server block and verify the configuration.
sudo ln -s /etc/nginx/sites-available/monicacrm /etc/nginx/sites-enabled/sudo nginx -t
Finally, restart the Nginx service.
sudo systemctl restart nginx
Accessing Monica CRM
You can now access Monica CRM by opening your web browser and visiting your domain name (e.g.,https://YOUR_DOMAIN.com). In the initial setup, you will be prompted to register an account for your Monica CRM installation. Enter your desired username, password, and email address, then click “Register.”
After registering, you will be redirected to the Monica CRM user dashboard, where you can start organizing your contacts, creating journals, and tracking important information about your relationships.
Conclusion
Congratulations! You have successfully installed Monica CRM on your Debian 11 server. By following this step-by-step guide, you have learned how to set up the LEMP Stack, install PHP dependencies, configure Nginx, and deploy Monica CRM. Now you can enjoy the benefits of this powerful open-source CRM and efficiently manage your personal and professional relationships.
For reliable and scalable Linux SSD VPS hosting services, consider Shape.host. Shape.host offers industry-leading cloud hosting solutions to empower your business with secure and efficient cloud infrastructure.
Tags:Debian 11 Installation and configuration Monica