How to Install Flectra on Ubuntu 18.04 | 20.04

How to Install Flectra on Ubuntu 18.04 20.04

In this article, we are going to shows that how to Install Flectra on Ubuntu 18.04 | 20.04.

Flectra is a free and open-source, CRM(customer relationship management) | ERP(enterprise resource planning) software system that is used to provides flexibility and customization that power up your business to the next level.

Flectra is written in the Python programming language with PostgreSQL as backend database. It is comes with a very simple and user-friendly web interface.

For more information about Flectra, please check its official website.


How to install Flectra on Ubuntu

Simply follow below steps to Install Flectra on Ubuntu 18.04 | 20.04:

Step 1 : Update & Install Required Dependencies

Before install Flectra, you will need to install Python packages and other required Flectra dependencies on your system. To update your system and install required dependencies, run the command below:

sudo apt update
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

After done with above command, next you will need to download and install wkhtmltopdf tool in your system by running 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 2 : Install PostgreSQL

PostgreSQL is requirement of Flectra to store its data in the database. To install it, run the command below:

sudo apt install postgresql

After installing PostgreSQL, Use PostgreSQL database utility to create and setup database the user for Flectra. To do that, run the command below:

su - postgres -c "createuser -s flectra"

The above command will create a user named “flectra”.


Step 3 : Install Flectra

To install Flectra, create a new system user account called flectra by using command below:

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

Now, run the command below to set a password for the newly created flectra user account:

sudo passwd flectra

After commands above, use Flectra user to 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

Next, run the commands below to create and activate a python virtual environment:

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

After open the file above, Find the below lines:

psycopg2==2.7.3.1; sys_platform != 'win32'
psycopg2==2.8.3; sys_platform == 'win32'

Now update them with the below lines:

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

After that, save and close the file.

Next, install the wheel and all required Python modules by running below commands:

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

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

deactivate
exit

Step 4 : Configure Flectra

Next, you will need to create a directory structure to support Flectra installation, configuration files and logs.

Run the commands below to create a directory:

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

Next, you will need to change the ownership of the above directories to Flectra user as show below:

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 by using command below:

sudo nano /etc/flectra/flectra.conf

After open the file, add the below lines:

[options]
admin_passwd = type_your_password
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 5 : Create a Systemd Service File

Next, you will need to create a systemd service file to manage the Flectra service like how Flectra is started, stopped and enable.

To create a systemd service file, run the command below:

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

Then add the below lines into the file:

[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

When you are done, Save and close the file.

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

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

You can check the Flectra status by running command below:

sudo systemctl status flectra

Step 6 : Install Configure Nginx Proxy for Flectra

 Next, you will need to install Nginx and configure it as a reverse proxy to use Flectra web portal because Flectra works better with a web server.

To do that, run the commands below:

sudo apt install nginx

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

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

Now, add the below lines into the configuration file and save it.

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

server {
   listen 80;
   server_name flectra.example.com;

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;
}

Replace example.com with your own domain or hostname.

Next, run the command below to enable the site and restart Nginx web server as show below:

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

At this stage, you are able to access the Flectra web portal using the hostname or domain name defined in Nginx configuration file.


Step 7 : Access the Flectra Web Portal

To access the Flectra web portal, open your favorite web browser and search for the URL http://flectra.example.com .

The search result redirected to Flectra setup wizard. At setup wizard fill your Master password that created in the configuration file above, database details, admin email, and password.

flectra-web-portal

That’s all.

If you face any error and issue in above steps , please use comment box below to report.

If our tutorials helped you, please consider buying us a coffee. We appreciate your support!

Thank you for your support.

If our tutorials helped you, please consider buying us a coffee. We appreciate your support!

Thank you for your support.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top