How To Install Flectra on Ubuntu 20.04 LTS

Install Flectra on Ubuntu 20.04

In this tutorial, we will show you how to install Flectra on Ubuntu 20.04 LTS. For those of you who didn’t know, Flectra is a free and open-source, CRM (customer relationship management) and ERP (enterprise resource planning) software system that provides a lot of flexibility and customization that lets you meet the unique needs of your business. Whether you’re a small or medium-sized business, Flectra comes with a modular suite of apps, including inventory, HR, CMS, POS, Project, etc. that will help you run a successful business today affordably.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you through the step-by-step installation of the Flectra open-source CRM and ERP on Ubuntu 20.04 (Focal Fossa). You can follow the same instructions for Ubuntu 18.04, 16.04, and any other Debian-based distribution like Linux Mint.

Install Flectra on Ubuntu 20.04 LTS Focal Fossa

Step 1. First, make sure that all your system packages are up-to-date by running the following apt commands in the terminal.

sudo apt update
sudo apt upgrade

Step 2. Installing Require Dependencies.

You can install all requirements of them using the following command:

sudo apt install gcc python3-venv build-essential python3-pillow python3-wheel python3-lxml python3-dev python3-pip python3-setuptools npm nodejs git gdebi libldap2-dev libsasl2-dev libxml2-dev libxslt1-dev libjpeg-dev libpq-dev

Step 3. Installing Wkhtmltopdf.

You will need to download and install wkhtmltopdf tool in your system by running the commands below:

cd /tmp
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb
sudo apt install ./wkhtmltox_0.12.5-1.bionic_amd64.deb

Step 4. Installing PostgreSQL.

Flectra requires PostgreSQL in order to store its data in a database. To install PostgreSQL on Ubuntu, run the commands below:

sudo apt install postgresql

Once done, use the PostgreSQL utility and create a user for Flectra with the following command. We named our user flectra, but you can use any name you like:

su - postgres -c "createuser -s flectra"

Step 5. Installing Install Flectra on Ubuntu 20.04.

First to install Flectra, create a new system user account called flectra by using the following command:

sudo useradd -m -U -r -d /opt/flectra -s /bin/bash flectra
sudo passwd flectra

Then, download Flectra packages from the official Git repository:

su - flectra
git clone --depth=1 --branch=1.0 https://gitlab.com/flectra-hq/flectra.git flectra

After that, create a Flectra virtual environment with the following command:

python3 -m venv flectra-venv
source flectra-venv/bin/activate

Next, run the commands below to open the requirement.txt file:

nano flectra/requirements.txt

Confirm these lines are there in the file:

psycopg2==2.8.5; sys_platform != 'win32'
psycopg2==2.8.5; sys_platform == 'win32'

Save and close the file then install the wheel module with the following command:

pip3 install wheel
pip3 install -r flectra/requirements.txt

When all required modules are installed, deactivate the virtual environment and exit by using the following command:

deactivate
exit

Step 6. Configure Flectra.

We need to create a directory structure for Flectra to store addons, configuration files, and logs. We can create it with the following command:

sudo mkdir /opt/flectra/flectra-custom-addons
sudo mkdir /var/log/flectra
sudo touch /var/log/flectra/flectra.log
sudo mkdir /etc/flectra

Next, change the ownership of the above directories:

sudo chown -R flectra:flectra /opt/flectra/flectra-custom-addons
sudo chown -R flectra:flectra /var/log/flectra/
sudo chown -R flectra:flectra /etc/flectra

Now, open Flectra configuration file:

sudo nano /etc/flectra/flectra.conf

Add the following file:

[options]
admin_passwd = your_stronge_password_here
db_host = False
db_port = False
db_user = flectra
db_password = False
logfile = /var/log/flectra/flectra.log
logrotate = True
proxy_mode = True
addons_path = /opt/flectra/flectra/addons, /opt/flectra/flectra-custom-addons

Step 7. Create a Systemd Service File for Flectra.

Now we create a systemd service file to manage the Flectra service. Create a new service file using this command:

sudo nano /etc/systemd/system/flectra.service

Then, add the lines below into the file and save:

[Unit]
Description=flectra
#Requires=postgresql-10.6.service
#After=network.target postgresql-10.6.service

[Service]
Type=simple
SyslogIdentifier=flectra
PermissionsStartOnly=true
User=flectra
Group=flectra
ExecStart=/opt/flectra/flectra-venv/bin/python3 /opt/flectra/flectra/flectra-bin -c /etc/flectra/flectra.conf
StandardOutput=journal+console

[Install]
WantedBy=multi-user.target

Next, reload the systemd daemon and after reload start and enable the Flectra service:

sudo systemctl daemon-reload
sudo systemctl start flectra
sudo systemctl enable flectra

Step 8. Configure Nginx as a Reverse Proxy for Flectra.

Now install the Nginx web server using the following command:

sudo apt install nginx

Next, create a new Nginx virtual host configuration file for Flectra:

sudo nano /etc/nginx/sites-available/example.conf

Add the following lines:

#flectra server
upstream flectra {
 server 127.0.0.1:7073;
}

server {
   listen 80;
   server_name flectra.idroot.us;

proxy_read_timeout 720s;
proxy_connect_timeout 720s;
proxy_send_timeout 720s;

 # Add Headers for flectra proxy mode
 proxy_set_header X-Forwarded-Host $host;
 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 proxy_set_header X-Forwarded-Proto $scheme;
 proxy_set_header X-Real-IP $remote_addr;

 # log
 access_log /var/log/nginx/flectra.access.log;
 error_log /var/log/nginx/flectra.error.log;

 # Redirect requests to flectra backend server
 location / {
   proxy_redirect off;
   proxy_pass http://localhost:7073;
 }

 # common gzip
 gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript;
 gzip on;
}

Save and close the file, then activate the Nginx virtual host file using the following command:

sudo ln -s /etc/nginx/sites-available/example.conf /etc/nginx/sites-enabled/
sudo systemctl restart nginx

Step 9. Accessing the Flectra Web Interface.

To access the Flectra web interface, open your favorite web browser and search for the URL http://flectra.idroot.us, You will be greeted by the database configuration page:

Install Flectra on Ubuntu 20.04

Congratulations! You have successfully installed Flectra. Thanks for using this tutorial for installing the Flectra open-source CRM and ERP on your Ubuntu 20.04 LTS Focal Fossa system. For additional help or useful information, we recommend you check the official Flectra website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!