Home / How To / How to install Flectra Business Management software with Nginx on CentOS 8

How to install Flectra Business Management software with Nginx on CentOS 8



Flectra is an open source and next generation business management software that combines CRM and ERP systems in a single package. The purpose is to enable users to modify the system according to their business needs and can easily add more tools to scale their business. Simply put, Flectra gives you a comprehensive platform so you can easily modify or configure it according to your needs. Flectra offers many functions 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.

Conditions

  • A server running CentOS 8 with at least 4 GB of RAM.
  • A root password is configured on your server.

Getting Started

First you need to update your system packages to the latest. You can do this with the following command:

dnf update -y

After updating all packages, it is recommended to disable SELinux in your system. You can disable it by editing the / etc / selinux / config file:

nano /etc/selinux/config

Change the following line:

SELINUX=disabled

Save and close the file, and then restart the server to apply the changes.

Install Python dependencies

Next, you need to install Python and other Flectra dependencies on your system. You can install them all 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

When all packages are installed, run the following command to install the Node.js module:

npm install -g less

Then you also need to install the wkhtmltopdf package in your system. You can download it from their official download page:

After downloading it, install the downloaded file with the following command:

dnf localinstall wkhtmltox-0.12.6-1.centos8.x86_64.rpm

When you are done, you can move on to the next step.

Install PostgreSQL

Flectra uses PostgreSQL as a database backend. So you need to install it on your server. You can install it with the following command:

dnf install postgresql-server -y

After installing the 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

Then start the PostgreSQL service and re-enable it at system startup with the following command:

systemctl start postgresql
systemctl enable postgresql

Then check 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 need to create a new PostgreSQL user for Flectra. You can create it with the following command:

su - postgres -c "createuser -s flectra"

When you are done, you can move on to the next step.

Install Flectra

Before installing Flectra, you must create a separate user for Flectra. You can create it with 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.

Then log in with Flectra users and download Flectra from the Git archive with the following command:

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

Then create a virtual environment for Flectra with the following command:

python3 -m venv my-flectra

Then activate the virtual environment with the following command:

source my-flectra/bin/activate

Then install all Python modules by running the following command:

pip3 install -r flectra/requirements.txt

When all modules are installed, disable the virtual environment with the following command:

deactivate

Then exit the Flectra user with the following command:

exit

Configure Flectra

First you need to create some directories for Flectra extensions, 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

Then change the ownership of the above directories to flectra with 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

Then 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 done.

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 done. Then reload the systemd daemon with the following command:

systemctl daemon-reload

Then start the Flectra service and make it possible to restart at system startup with the following command:

systemctl start flectra
systemctl enable flectra

You can now check the status of the Flectra service with the following command:

systemctl status flectra

If all goes well, 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 run Flectra and listen to port 7073. You can verify this 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 need to configure Nginx as a reverse proxy for Flectra. So you can access Flectra with 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 when the system restarts:

systemctl start nginx
systemctl enable nginx

Then 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 done. Then restart the Nginx service to apply the changes:

systemctl restart nginx

At this time, the Nginx web server is configured to serve Flectra. You can now move on to the next step.

Go to the Flectra Web UI

Now open your browser and enter the URL http://flectra.your-domain.com. You will be redirected to the following screen:

Database information

Enter your master password that you have defined in the configuration file, database information, email, password and click Create database button. You should see the Flectra dashboard displayed on the following screen:

Flectra CRM and ERP

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 lots of add-ons. For more information about Flectra, read Flectra’s official documentation.


Source link