Flectra is an open-source and next-generation business management software that combines CRM and ERP systems into a single package. Its aim is to enable users to modify the system as per their business needs and can easily add more tools to scale their business. In simple terms, Flectra gives you a comprehensive platform so that you can easily modify or configure as per your requirements. Flectra provides a lot of features such as Accounting, E-Commerce, Inventory Management, Marketing, Project Management, CRM, Reporting, Leave Management and many more.
In this tutorial, we will show you how to install Flectra with Nginx on CentOS 8.
Prerequisites
- A server running CentOS 8 with a minimum of 4 GB of RAM.
- A root password is configured in your server.
Getting Started
First, you will need to update your system packages to the latest one. You can do it with the following command:
dnf update -y
After updating all the packages, it is recommended to disable the SELinux in your system. You can disable it by editing the file /etc/selinux/config:
nano /etc/selinux/config
Change the following line:
SELINUX=disabled
Save and close the file then restart your server to apply the changes.
Install Python Dependencies
Next, you will need to install Python and other Flectra dependencies in your system. You can install all of them by running the following command:
dnf install python36 python36-devel git gcc wget nodejs libxslt-devel bzip2-devel openldap-devel libjpeg-devel freetype-devel -y
Once all the packages are installed, run the following command to install Node.js module:
npm install -g less
Next, you will also need to install wkhtmltopdf package in your system. You can download it from their official download page:
Once downloaded, install the downloaded file with the following command:
dnf localinstall wkhtmltox-0.12.6-1.centos8.x86_64.rpm
Once you are done, you can proceed to the next step.
Install PostgreSQL
Flectra uses PostgreSQL as a database backend. So you will need to install it in your server. You can install it with the following command:
dnf install postgresql-server -y
After installing PostgreSQL server, initialize the database with the following command:
postgresql-setup --initdb --unit postgresql
You should get the following output:
* Initializing database in '/var/lib/pgsql/data' * Initialized, logs are in /var/lib/pgsql/initdb_postgresql.log
Next, start the PostgreSQL service and enable it to start at system reboot with the following command:
systemctl start postgresql
systemctl enable postgresql
Next, verify the status of the PostgreSQL service with the following command:
systemctl status postgresql-12
You should get the following output:
? postgresql-12.service - PostgreSQL 12 database server Loaded: loaded (/usr/lib/systemd/system/postgresql-12.service; disabled; vendor preset: disabled) Active: active (running) since Thu 2020-08-13 04:39:31 EDT; 7s ago Docs: https://www.postgresql.org/docs/12/static/ Process: 1176 ExecStartPre=/usr/pgsql-12/bin/postgresql-12-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS) Main PID: 1182 (postmaster) Tasks: 8 (limit: 12537) Memory: 17.3M CGroup: /system.slice/postgresql-12.service ??1182 /usr/pgsql-12/bin/postmaster -D /var/lib/pgsql/12/data/ ??1183 postgres: logger ??1185 postgres: checkpointer ??1186 postgres: background writer ??1187 postgres: walwriter ??1188 postgres: autovacuum launcher ??1189 postgres: stats collector ??1190 postgres: logical replication launcher Aug 13 04:39:31 centos8 systemd[1]: Starting PostgreSQL 12 database server... Aug 13 04:39:31 centos8 postmaster[1182]: 2020-08-13 04:39:31.136 EDT [1182] LOG: starting PostgreSQL 12.3 on x86_64-pc-linux-gnu, compiled b> Aug 13 04:39:31 centos8 postmaster[1182]: 2020-08-13 04:39:31.137 EDT [1182] LOG: listening on IPv6 address "::1", port 5432 Aug 13 04:39:31 centos8 postmaster[1182]: 2020-08-13 04:39:31.137 EDT [1182] LOG: listening on IPv4 address "127.0.0.1", port 5432 Aug 13 04:39:31 centos8 postmaster[1182]: 2020-08-13 04:39:31.139 EDT [1182] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" Aug 13 04:39:31 centos8 postmaster[1182]: 2020-08-13 04:39:31.142 EDT [1182] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432" Aug 13 04:39:31 centos8 postmaster[1182]: 2020-08-13 04:39:31.161 EDT [1182] LOG: redirecting log output to logging collector process Aug 13 04:39:31 centos8 postmaster[1182]: 2020-08-13 04:39:31.161 EDT [1182] HINT: Future log output will appear in directory "log". Aug 13 04:39:31 centos8 systemd[1]: Started PostgreSQL 12 database server.
Next, you will need to create a new PostgreSQL user for Flectra. You can create it with the following command:
su - postgres -c "createuser -s flectra"
Once you are finished, you can proceed to the next step.
Install Flectra
Before installing Flectra, you will need to create a separate user for Flectra. You can create it using the following command:
useradd -m -U -r -d /opt/flectra -s /bin/bash flectra
Note : Make sure the username must be the same as PostgreSQL user.
Next, login with Flectra user and download Flectra from the Git repository with the following command:
su - flectra
git clone --depth=1 --branch=1.0 https://gitlab.com/flectra-hq/flectra.git flectra
Next, create a virtual environment for Flectra with the following command:
python3 -m venv my-flectra
Next, activate the virtual environment with the following command:
source my-flectra/bin/activate
Next, install all Python modules by running the following command:
pip3 install -r flectra/requirements.txt
Once all the modules are installed, deactivate the virtual environment with the following command:
deactivate
Next, exit from the Flectra user using the following command:
exit
Configure Flectra
First, you will need to create some directories for Flectra addons, configuration file and log. You can create them with the following command:
mkdir /opt/flectra/flectra-custom-addons
mkdir /var/log/flectra
mkdir /etc/flectra
touch /var/log/flectra/flectra.log
Next, change the ownership of the above directories to flectra using the following command:
chown -R flectra:flectra /opt/flectra/flectra-custom-addons
chown -R flectra:flectra /var/log/flectra/
chown -R flectra:flectra /etc/flectra
Next, create a Flectra configuration file with the following command:
nano /etc/flectra/flectra.conf
Add the following lines:
[options] admin_passwd = your-flectra-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
Save and close the file when you are finished.
Create Systemd Service File for Flectra
Next, you will need to create a systemd service file for Flectra to manage the Flectra service. You can create it with the following command:
nano /etc/systemd/system/flectra.service
Add the following lines:
[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/my-flectra/bin/python3 /opt/flectra/flectra/flectra-bin -c /etc/flectra/flectra.conf StandardOutput=journal+console [Install] WantedBy=multi-user.target
Save and close the file when you are finished. Then, reload the systemd daemon with the following command:
systemctl daemon-reload
Next, start the Flectra service and enable it to start at system reboot with the following command:
systemctl start flectra
systemctl enable flectra
You can now check the status of Flectra service with the following command:
systemctl status flectra
If everything is fine, you should get the following output:
? flectra.service - flectra Loaded: loaded (/etc/systemd/system/flectra.service; disabled; vendor preset: disabled) Active: active (running) since Thu 2020-08-13 05:34:15 EDT; 1min 3s ago Main PID: 10917 (python3) Tasks: 4 (limit: 25028) Memory: 57.9M CGroup: /system.slice/flectra.service ??10917 /opt/flectra/my-flectra/bin/python3 /opt/flectra/flectra/flectra-bin -c /etc/flectra/flectra.conf Aug 13 05:34:15 centos8 systemd[1]: Started flectra.
Now, Flectra is running and listening on port 7073. You can verify it with the following command:
netstat -plntu | grep 7073
You should see the following output:
tcp 0 0 0.0.0.0:7073 0.0.0.0:* LISTEN 10917/python3
Configure Nginx for Flectra
Next, you will need to configure Nginx as a reverse proxy for Flectra. So you can access the Flectra using the port 80.
First, install the Nginx web server using the following command:
dnf install nginx -y
After installing Nginx, start the Nginx service and enable it to start at system reboot:
systemctl start nginx
systemctl enable nginx
Next, create a new Nginx virtual host configuration file for Flectra:
nano /etc/nginx/conf.d/flectra.conf
Add the following lines:
#flectra server upstream flectra { server 127.0.0.1:7073; } server { listen 80; server_name flectra.your-domain.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://flectra; } # 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 when you are finished. Then, restart the Nginx service to apply the changes:
systemctl restart nginx
At this point, the Nginx web server is configured to serve Flectra. You can now proceed to the next step.
Access Flectra Web UI
Now, open your web browser and type the URL http://flectra.your-domain.com. You will be redirected to the following screen:
Provide your Master password that you have defined in the configuration file, database details, email, password and click on the Create database button. You should see Flectra dashboard as shown in the following screen:
Conclusion
Congratulations! you have successfully installed Flectra with Nginx on CentOS 8. You can now host your own Flectra business information system and grow your business with Flectra's powerful modular design and tons of add-ons. For more information about Flectra, you can read the Flectra official documentation.